ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-08-22 06:48:56
Exec Total Coverage
Lines: 9203 12208 75.4%
Functions: 378 436 86.7%
Branches: 7299 12917 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113385 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113385 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1113108 times.
1113385 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1113108 times.
1113108 if (c < 0)
56 c -= val / 2;
57 1113108 else c += (val/2);
58 1113108 }
59 1113385 c -= c % val;
60 1113385 coord = c;
61 1113385 }
62
63 38564049 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38047443 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38562834 times.
38564049 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38532514 times.
38562834 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38532514 times.
38532514 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38532448 times.
38532514 if (x > world_w+256) return true;
69 38532448 return false;
70 38564049 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 422 void identifyCFEnemies()
108 {
109 422 trapConstantHorizontalID=-1;
110 422 trapConstantVerticalID=-1;
111 422 trapLOSHorizontalID=-1;
112 422 trapLOSVerticalID=-1;
113 422 trapLOS4WayID=-1;
114 422 cornerTrapID=-1;
115 422 centerTrapID=-1;
116 422 rockID=-1;
117 422 zoraID=-1;
118 422 statueID=-1;
119
120
2/2
✓ Branch 0 taken 216064 times.
✓ Branch 1 taken 422 times.
216486 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 215647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 417 times.
216064 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 417 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 215636 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 422 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 422 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 422 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 422 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 422 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 422 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 422 rockID=i;
140
4/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 215619 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 419 times.
216064 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 419 zoraID=i;
142
143
4/4
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 215579 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 422 statueID=i;
145 216064 }
146 422 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806969 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600909 times.
✓ Branch 1 taken 206060 times.
806969 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12361841 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177577154 times.
✓ Branch 1 taken 12335380 times.
189912534 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177550693 times.
177577154 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177550693 }
273 }
274 12335380 return false;
275 12361841 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438667 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438667 times.
7438667 if(moveflags & move_ignore_blockflags) return false;
281 7438667 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895519 times.
✓ Branch 1 taken 2543148 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142761 times.
9981815 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524824 times.
✓ Branch 1 taken 4913843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438667 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584370 times.
✓ Branch 1 taken 4854297 times.
✓ Branch 2 taken 2582493 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582493 times.
✗ Branch 5 not taken.
14878098 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582493 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433745 times.
✓ Branch 5 taken 148748 times.
2582493 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577217 times.
✓ Branch 1 taken 2428469 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574547 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574300 times.
✓ Branch 3 taken 247 times.
2577217 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573482 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573416 times.
✓ Branch 3 taken 66 times.
2574300 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562790 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146537 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998463 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2573121 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2587011 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696119 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696119 times.
8696119 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098982 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348778 times.
10795101 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084475 times.
✓ Branch 2 taken 2084475 times.
✗ Branch 3 not taken.
10780594 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1202011 times.
✓ Branch 1 taken 7494108 times.
16190227 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696119 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282052 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282052 int32_t c = COMBOTYPE(dx,dy);
314 282052 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246498 times.
282052 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282032 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281915 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281915 times.
✗ Branch 5 not taken.
1062905 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281915 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250042 times.
✓ Branch 5 taken 31873 times.
281915 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281342 times.
✓ Branch 1 taken 249469 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280955 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280924 times.
✓ Branch 3 taken 31 times.
281342 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277269 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276994 times.
✓ Branch 3 taken 275 times.
280924 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275950 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553949 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223787 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
230480 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115240 {
344
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 x=X;
345
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 y=Y;
346
3/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115240 id=Id;
348 115240 clk=Clk;
349
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 floor_y=y;
350 115240 ceiling=false;
351 115240 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115240 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115240 did_armos=true;
355 115240 script_spawned=false;
356
357 115240 d = guysbuf + (id & 0xFFF);
358 115240 hp = d->hp;
359 115240 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115240 flags=d->flags;
364 115240 flags=d->flags;
365 115240 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115240 type=d->type;
367 115240 dcset=d->cset;
368 115240 cs=dcset;
369
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115240 dp=d->dp;
371 115240 wdp=d->wdp;
372 115240 wpn=d->weapon;
373 115240 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115240 rate=d->rate;
375 115240 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dstep=d->step;
377 115240 homing=d->homing;
378 115240 dmisc1=d->attributes[0];
379 115240 dmisc2=d->attributes[1];
380 115240 dmisc3=d->attributes[2];
381 115240 dmisc4=d->attributes[3];
382 115240 dmisc5=d->attributes[4];
383 115240 dmisc6=d->attributes[5];
384 115240 dmisc7=d->attributes[6];
385 115240 dmisc8=d->attributes[7];
386 115240 dmisc9=d->attributes[8];
387 115240 dmisc10=d->attributes[9];
388 115240 dmisc11=d->attributes[10];
389 115240 dmisc12=d->attributes[11];
390 115240 dmisc13=d->attributes[12];
391 115240 dmisc14=d->attributes[13];
392 115240 dmisc15=d->attributes[14];
393 115240 dmisc16=d->attributes[15];
394 115240 dmisc17=d->attributes[16];
395 115240 dmisc18=d->attributes[17];
396 115240 dmisc19=d->attributes[18];
397 115240 dmisc20=d->attributes[19];
398 115240 dmisc21=d->attributes[20];
399 115240 dmisc22=d->attributes[21];
400 115240 dmisc23=d->attributes[22];
401 115240 dmisc24=d->attributes[23];
402 115240 dmisc25=d->attributes[24];
403 115240 dmisc26=d->attributes[25];
404 115240 dmisc27=d->attributes[26];
405 115240 dmisc28=d->attributes[27];
406 115240 dmisc29=d->attributes[28];
407 115240 dmisc30=d->attributes[29];
408 115240 dmisc31=d->attributes[30];
409 115240 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 110965 times.
115240 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110965 dmisc31 = dmisc32;
413 110965 dmisc32 = 0;
414 110965 }
415 115240 spr_shadow=d->spr_shadow;
416 115240 spr_death=d->spr_death;
417 115240 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724840 times.
✓ Branch 1 taken 115240 times.
4840080 for(int32_t i=0; i<edefLAST255; i++)
420 4724840 defense[i]=d->defense[i];
421
422 115240 bgsfx=d->bgsfx;
423 115240 hitsfx=d->hitsfx;
424 115240 deadsfx=d->deadsfx;
425 115240 bosspal=d->bosspal;
426
427 115240 frozentile = d->frozentile;
428
429 115240 frozencset = d->frozencset;
430 115240 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152400 times.
✓ Branch 1 taken 115240 times.
1267640 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1959080 times.
✓ Branch 1 taken 115240 times.
2074320 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115240 isCore = true; //t.b.a
436 115240 parentCore = 0; //t.b.a
437
438 115240 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115240 script = d->script;
443
444
2/2
✓ Branch 0 taken 921920 times.
✓ Branch 1 taken 115240 times.
1037160 for ( int32_t q = 0; q < 8; q++ )
445 {
446 921920 initD[q] = d->initD[q];
447 921920 }
448
449 115240 stickclk = 0;
450 115240 submerged = false;
451 115240 didScriptThisFrame = false;
452 115240 ffcactivated = std::nullopt;
453 115240 hitdir = -1;
454 115240 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106319 times.
115240 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
462 8921 }
463
464
2/2
✓ Branch 0 taken 50331 times.
✓ Branch 1 taken 64909 times.
115240 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50331 times.
✗ Branch 1 not taken.
50331 cont_sfx(bgsfx);
467 50331 }
468
469
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89096 o_tile=d->e_tile;
472 89096 frate = d->e_frate;
473 89096 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 115240 tile=0; //init to 0 here, but set it later.
481
482 115240 scripttile = -1;
483 115240 scriptflip = -1;
484 115240 do_animation = true;
485 115240 immortal = false;
486 115240 noSlide = false;
487 115240 deathexstate = -1;
488
489 115240 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109447 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115240 if(o_tile==0 && type!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102943 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115240 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102244 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102943 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
115240 step = zslongToFix(dstep*100);
501
502
503 115240 item_set = d->item_set;
504 115240 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90351 times.
✓ Branch 1 taken 24889 times.
115240 if(frate == 0)
507 24889 frate = 256;
508
509 115240 leader = itemguy = dying = scored = false;
510 115240 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115240 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114874 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115240 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 7242 times.
115240 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115240 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97534 times.
115240 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
548 17706 }
549
550 115240 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115240 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 weap_data = d->weap_data;
554 115240 }
555
556 114983 enemy::~enemy()
557 114983 {
558
1/2
✓ Branch 0 taken 114983 times.
✗ Branch 1 not taken.
114983 FFCore.destroySprite(this);
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114970 times.
114983 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114983 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 38011691 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 38009324 times.
✓ Branch 1 taken 2367 times.
38011691 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 38011680 return false;
1022 38011691 }
1023
1024 // Handle drowning in water
1025 38009324 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 38009324 times.
✗ Branch 1 not taken.
38009324 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 38009324 return false;
1063 38009324 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38674710 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38672881 times.
38674710 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 765577 times.
✓ Branch 1 taken 37907304 times.
38672881 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765577 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 765577 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 39920 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
765577 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 722043 times.
✓ Branch 1 taken 43534 times.
765577 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42830 times.
✓ Branch 1 taken 704 times.
43534 if(flags&guy_never_return)
1091 704 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43463 times.
✓ Branch 1 taken 71 times.
43534 if(leader)
1094 71 kill_em_all();
1095
1096 43534 leave_item();
1097 43534 }
1098
1099 765577 stop_bgsfx(index);
1100 765577 return (clk2==0);
1101 }
1102
1103 37907304 return false;
1104 38674710 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 38011947 bool enemy::animate(int32_t index)
1110 {
1111
2/2
✓ Branch 0 taken 1723938 times.
✓ Branch 1 taken 36288009 times.
38011947 if(sclk <= 0) hitdir = -1;
1112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38011691 times.
38011947 if(switch_hooked)
1113 {
1114
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1115 {
1116 //Run its script
1117 if (!didScriptThisFrame)
1118 {
1119 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1120 {
1121 return 0; //Avoid NULLPO if this object deleted itself
1122 }
1123 }
1124 }
1125 256 return false;
1126 }
1127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38011680 times.
38011691 if(do_falling(index)) return true;
1128
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38009324 times.
38011680 else if(fallclk)
1129 {
1130 //clks
1131
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1132 704 --hclk;
1133
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1134 --stunclk;
1135
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1136 --frozenclock;
1137
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1138 {
1139 Hero.setX(x);
1140 Hero.setY(y);
1141 Hero.fallCombo = fallCombo;
1142 Hero.fallclk = fallclk;
1143
1144 if(hashero)
1145 {
1146 hashero = false; //Let Hero go if falling
1147 Hero.setEaten(0);
1148 }
1149 }
1150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1151 {
1152 2356 run_script(MODE_NORMAL);
1153 2356 }
1154 2356 return false;
1155 }
1156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if(do_drowning(index)) return true;
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 else if(drownclk)
1158 {
1159 //clks
1160 if(hclk>0)
1161 --hclk;
1162 if(stunclk>0)
1163 --stunclk;
1164 if ( frozenclock > 0 )
1165 --frozenclock;
1166 if(hashero)
1167 {
1168 Hero.setX(x);
1169 Hero.setY(y);
1170 Hero.drownclk = drownclk;
1171
1172 if(hashero)
1173 {
1174 hashero = false; //Let Hero go if falling
1175 Hero.setEaten(0);
1176 }
1177 }
1178 if (!didScriptThisFrame)
1179 {
1180 run_script(MODE_NORMAL);
1181 }
1182 return false;
1183 }
1184 38009324 int32_t nx = real_x(x);
1185 38009324 int32_t ny = real_y(y);
1186
1187
4/4
✓ Branch 0 taken 27480339 times.
✓ Branch 1 taken 10528985 times.
✓ Branch 2 taken 5660595 times.
✓ Branch 3 taken 21819744 times.
38009324 if(ox!=nx || oy!=ny)
1188 {
1189 16189580 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1190 16189580 }
1191
1192 38009324 ox = nx;
1193 38009324 oy = ny;
1194
1195 // Maybe they fell off the bottom in sideview, or were moved by a script.
1196
1197 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1198
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38007495 times.
38009324 if ( immortal )
1199 {
1200 //skip, as it can go out of bounds, from immortality
1201 1829 }
1202
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38007495 times.
✓ Branch 2 taken 38007495 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38007495 times.
38007495 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1203 {
1204 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1205 }
1206
2/2
✓ Branch 0 taken 37975894 times.
✓ Branch 1 taken 31601 times.
38007495 else if (OUTOFBOUNDS(id, x, y))
1207 {
1208 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1209 31601 }
1210 //fall down
1211
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10816761 times.
✓ Branch 2 taken 10546498 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511441 times.
✓ Branch 5 taken 10035057 times.
38009324 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1212 {
1213
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647359 times.
10035057 if(isSideViewGravity())
1214 {
1215
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1216 {
1217
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1218 {
1219 157378 bool willHitSVPlatform = false;
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1222
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1223 {
1224
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1225 {
1226 willHitSVPlatform = true;
1227 break;
1228 }
1229 157378 }
1230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1231 {
1232 y+=fall/100;
1233 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1234 do_fix(y, 16); //Fix to top of SV Ladder
1235 fall = 0;
1236 }
1237 else
1238 {
1239 157378 y+=fall/100;
1240
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1241 139566 fall += (zinit.gravity/100);
1242 }
1243 157378 }
1244 else
1245 {
1246
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1247 {
1248 //y-=(int32_t)y%8; // Fix position
1249 277 do_fix(y, 8); //Fix position
1250 277 }
1251
1252 230320 fall = 0;
1253 }
1254 387698 }
1255 else
1256 {
1257 if(isOnSideviewPlatform())
1258 fall = 0;
1259 else
1260 {
1261 zfix fall_amnt = fall/100;
1262 bool hit = false;
1263 while(fall_amnt >= 1)
1264 {
1265 --fall_amnt;
1266 ++y;
1267 if(isOnSideviewPlatform())
1268 {
1269 y = y.getInt();
1270 fall_amnt = 0;
1271 hit = true;
1272 break;
1273 }
1274 }
1275 if(fall_amnt > 0)
1276 y += fall_amnt;
1277 if(fall_amnt < 0)
1278 {
1279 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1280 hit = true;
1281 }
1282 if(hit)
1283 fall = 0;
1284 else if(fall <= (int32_t)zinit.terminalv)
1285 fall += (zinit.gravity/100);
1286 }
1287 }
1288 387698 }
1289 else
1290 {
1291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_fake_z))
1292 {
1293
2/2
✓ Branch 0 taken 5079296 times.
✓ Branch 1 taken 4568063 times.
9647359 if(fakefall!=0)
1294 4568063 fakez-=(fakefall/100);
1295
1296
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5079296 times.
9647359 if(fakez<0)
1297 4568063 fakez = fakefall = 0;
1298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5079296 times.
5079296 else if(fakefall <= (int32_t)zinit.terminalv)
1299 5079296 fakefall += (zinit.gravity/100);
1300
1301
5/6
✓ Branch 0 taken 9647359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5079296 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496986 times.
9647359 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1302 9647359 }
1303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_real_z))
1304 {
1305
2/2
✓ Branch 0 taken 5512182 times.
✓ Branch 1 taken 4135177 times.
9647359 if(fall!=0)
1306 4135177 z-=(fall/100);
1307
1308
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526754 times.
9647359 if(z<0)
1309 4120605 z = fall = 0;
1310
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516697 times.
5526754 else if(fall <= (int32_t)zinit.terminalv)
1311 5516697 fall += (zinit.gravity/100);
1312
1313
6/6
✓ Branch 0 taken 9605145 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484540 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493851 times.
9647359 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1314 9647359 }
1315
1316 }
1317 10035057 }
1318
9/10
✓ Branch 0 taken 29780223 times.
✓ Branch 1 taken 8229101 times.
✓ Branch 2 taken 28485223 times.
✓ Branch 3 taken 1295000 times.
✓ Branch 4 taken 28485223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4179477 times.
✓ Branch 7 taken 25600746 times.
✓ Branch 8 taken 18452882 times.
✓ Branch 9 taken 22632359 times.
38009324 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1319 {
1320
4/4
✓ Branch 0 taken 22216835 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13056224 times.
✓ Branch 3 taken 9160611 times.
22632359 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1321 9160611 fallCombo = check_pits();
1322
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 22216835 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 22074937 times.
22632359 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1323 141898 drownCombo = check_water();
1324 22632359 }
1325
1326 74915088 runKnockback(); //scripted knockback handling
1327
1328 // clk is incremented here
1329
2/2
✓ Branch 0 taken 72604719 times.
✓ Branch 1 taken 2310369 times.
74915088 if(++clk >= frate)
1330 2310369 clk=0;
1331
1332 // hit and death handling
1333
2/2
✓ Branch 0 taken 1255709 times.
✓ Branch 1 taken 73659379 times.
74915088 if(hclk>0)
1334 1255709 --hclk;
1335
1336
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 74238843 times.
74915088 if(stunclk>0)
1337 676245 --stunclk;
1338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74915088 times.
74915088 if ( frozenclock > 0 )
1339 --frozenclock;
1340
1341
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 74900212 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
74915088 if(ceiling && z <= 0 && fakez <= 0)
1342 124 ceiling = false;
1343
1344 74915088 try_death();
1345
1346 74915088 scored=false;
1347
1348 74915088 ++c_clk;
1349
1350 //Run its script
1351
2/2
✓ Branch 0 taken 36930581 times.
✓ Branch 1 taken 37984507 times.
74915088 if (!didScriptThisFrame)
1352 {
1353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37984507 times.
37984507 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1354 {
1355 return 0; //Avoid NULLPO if this object deleted itself
1356 }
1357 37984507 }
1358
1359 // returns true when enemy is defeated
1360 74915088 return Dead(index);
1361 74917711 }
1362
1363 38761623 bool enemy::setSolid(bool set)
1364 {
1365
1/2
✓ Branch 0 taken 38761623 times.
✗ Branch 1 not taken.
38761623 bool actual = set && !isSubmerged();
1366 38761623 bool ret = solid_object::setSolid(actual);
1367 38761623 solid = set;
1368 38761623 return ret;
1369 }
1370 void enemy::doContactDamage(int32_t hdir)
1371 {
1372 Hero.hithero(guys.find(this), hdir);
1373 }
1374
1375 22405 void enemy::solid_push(solid_object *obj)
1376 {
1377
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1379 22405 zfix dx, dy;
1380 22405 int32_t hdir = -1;
1381 22405 solid_push_int(obj,dx,dy,hdir,true);
1382
1383
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1384
1385 263 bool t = obj->getTempNonsolid();
1386 263 obj->setTempNonsolid(true);
1387
1388 263 int32_t ydir = dy > 0 ? down : up;
1389 263 int32_t xdir = dx > 0 ? right : left;
1390
1391 263 auto special = isflier(id) ? spw_floater : spw_none;
1392
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1393 {
1394 //Crushed?
1395 7 }
1396
1397 263 obj->setTempNonsolid(t);
1398 22405 }
1399 22405 bool enemy::is_unpushable() const
1400 {
1401 22405 return isSubmerged();
1402 }
1403 22087 bool enemy::sideview_mode() const
1404 {
1405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1406 }
1407
1408 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1409 {
1410 3234 int32_t yg = (special==spw_floater)?8:0;
1411 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1412
1413
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1414 4732 return true;
1415
1416 3238 bool isInDungeon = isdungeon(screen_spawned);
1417
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1418 {
1419
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1420 1199 return true;
1421
1422
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1423
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1424 return true;
1425 595 }
1426
1427
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1428 {
1429
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1430
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1431 return true;
1432 62 }
1433
1434
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1435 {
1436 case spw_clipbottomright:
1437 if(dy>=128 || dx>=208) return true;
1438 break;
1439 case spw_clipright:
1440 break; //if(x>=208) return true; break;
1441
1442 case spw_wizzrobe: // fall through
1443 case spw_floater: // Special case for fliers and wizzrobes - hack!
1444 {
1445
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1446 {
1447
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1448
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1449 595 }
1450 857 return false;
1451 }
1452 }
1453
1454 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1455 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1456
1457 if(special==spw_water)
1458 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1459
1460 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1461 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1462 870 }
1463
1464 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1465 {
1466 6575 bool kb = false;
1467 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1468
1469
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1470 return true;
1471
1472
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1473 {
1474
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1475 return true;
1476
1477
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1478 return true;
1479 1513 }
1480
1481
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1482 {
1483
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1484
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1485 return true;
1486 6575 }
1487
1488
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1489 {
1490
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1492 }
1493 else
1494 {
1495
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1496
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1497
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1499 }
1500 6575 }
1501
1502 // returns true if cannot walk
1503 32505729 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1504 {
1505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505729 times.
32505729 if(moveflags & move_new_movement)
1506 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1507 32505729 int32_t yg = (special==spw_floater)?8:0;
1508 32505729 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1509
2/2
✓ Branch 0 taken 3724406 times.
✓ Branch 1 taken 28781323 times.
32505729 switch(dir)
1510 {
1511 case l_down:
1512 case r_down:
1513 case down:
1514 case 11: //r_down
1515 case 12: //down
1516 case 13: //l_down
1517 {
1518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724406 times.
3724406 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1519 {
1520
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724406 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1521 {
1522 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1523
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1524 8 }
1525 3724406 }
1526 3724406 break;
1527 }
1528 }
1529
2/2
✓ Branch 0 taken 3726357 times.
✓ Branch 1 taken 28779372 times.
32505729 switch(dir)
1530 {
1531 case r_up:
1532 case r_down:
1533 case right:
1534 case 9: //r_up
1535 case 10: //right
1536 case 11: //r_down
1537 {
1538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726357 times.
3726357 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1539 {
1540
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726357 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1541 {
1542 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1543
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1544 3 }
1545 3726357 }
1546 3726357 break;
1547 }
1548 }
1549
1550
10/10
✓ Branch 0 taken 22401875 times.
✓ Branch 1 taken 10103854 times.
✓ Branch 2 taken 8754457 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066678 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043475 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454867 times.
✓ Branch 9 taken 32498342 times.
32505729 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1551 44917121 return true;
1552
1553 32498342 bool isInDungeon = isdungeon(screen_spawned);
1554
4/4
✓ Branch 0 taken 3976583 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964827 times.
32498342 if(isInDungeon || special==spw_wizzrobe)
1555 {
1556
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1557 11487907 return true;
1558
1559
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1560
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1561 113905 return true;
1562 5785039 }
1563
1564
6/6
✓ Branch 0 taken 3102356 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750728 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699498 times.
9749866 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1565 {
1566
4/4
✓ Branch 0 taken 3044709 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043757 times.
6094933 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1567
4/4
✓ Branch 0 taken 3044526 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043807 times.
✓ Branch 3 taken 719 times.
3044709 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1568 7369 return true;
1569 3043757 }
1570
1571
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180546 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742497 switch(special)
1572 {
1573 case spw_clipbottomright:
1574
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1575 707 break;
1576 case spw_clipright:
1577 5281 break; //if(input_x>=208) return true; break;
1578
1579 case spw_wizzrobe: // fall through
1580 case spw_floater: // Special case for fliers and wizzrobes - hack!
1581 {
1582
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1583 {
1584
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1585
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1586 4639539 }
1587 7553557 return false;
1588 }
1589 }
1590
1591 2186534 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1592
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699945 times.
2186534 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1593
1594
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771857 times.
2186534 if(special==spw_water)
1595
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1596
1597
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 59949 times.
1771857 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1598 {
1599
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1600
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1601 }
1602 else
1603 {
1604
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17040 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102594 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1605
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1606
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1607
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1608 }
1609 10129559 }
1610
1611 496901 bool enemy::isOnSideviewPlatform()
1612 {
1613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1616 return false;
1617
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1619
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1620 {
1621
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1622
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1624 64328 }
1625 215641 return false;
1626 496901 }
1627
1628 // Stops playing the given sound only if there are no enemies left to play it
1629 768489 void enemy::stop_bgsfx(int32_t index)
1630 {
1631
2/2
✓ Branch 0 taken 753379 times.
✓ Branch 1 taken 15110 times.
768489 if(bgsfx<=0)
1632 753379 return;
1633
1634 // Look for other enemies with the same bgsfx
1635
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1636 {
1637
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1638 6304 return;
1639 46690 }
1640
1641 8806 stop_sfx(bgsfx);
1642 768489 }
1643
1644
1645 // to allow for different sfx on defeating enemy
1646 40356 void enemy::death_sfx()
1647 {
1648
2/2
✓ Branch 0 taken 40071 times.
✓ Branch 1 taken 285 times.
40356 if(deadsfx > 0) sfx(deadsfx,pan(x));
1649 40356 }
1650
1651 void enemy::move(zfix dx,zfix dy)
1652 {
1653 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1654 {
1655 x+=dx;
1656 y+=dy;
1657 }
1658 }
1659
1660 18374579 void enemy::move(zfix s)
1661 {
1662
9/10
✓ Branch 0 taken 18374540 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18265431 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18374579 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1663 {
1664 18373535 sprite::move(s);
1665 18373535 }
1666 18374579 }
1667
1668 43836 void enemy::leave_item()
1669 {
1670 43836 int32_t drop_item = select_dropitem(item_set, x, y);
1671 43836 int32_t thedropset = item_set;
1672
1673 43836 std::vector<int32_t> &ev = FFCore.eventData;
1674 43836 ev.clear();
1675 43836 ev.push_back(getUID());
1676 43836 ev.push_back(drop_item*10000);
1677 43836 ev.push_back(thedropset*10000);
1678
1679 43836 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1680 43836 drop_item = vbound(ev[1] / 10000,-2,255);
1681 43836 thedropset = ev[2] / 10000;
1682 43836 ev.clear();
1683
1/2
✓ Branch 0 taken 43836 times.
✗ Branch 1 not taken.
43836 if(drop_item == -2)
1684 {
1685 drop_item = select_dropitem(thedropset,x,y);
1686 }
1687
1688
6/6
✓ Branch 0 taken 16545 times.
✓ Branch 1 taken 27291 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15628 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43836 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1689 {
1690 item* itm;
1691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16376 times.
16376 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1692 {
1693 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1694 }
1695 else
1696 {
1697
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1698
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1699 }
1700 16376 itm->from_dropset = thedropset;
1701 16376 add_item_for_screen(screen_spawned, itm);
1702
1703 16376 ev.push_back(getUID());
1704 16376 ev.push_back(itm->getUID());
1705
1706 16376 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1707 16376 ev.clear();
1708 16376 }
1709 43836 }
1710
1711 // auomatically kill off enemy (for rooms with ringleaders)
1712 411 void enemy::kickbucket()
1713 {
1714
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1715 379 hp=-1000; // don't call death_sfx()
1716 411 }
1717
1718 21250 bool enemy::isSubmerged() const
1719 {
1720 21250 return submerged;
1721 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1722 }
1723
1724 20952 void enemy::FireBreath(bool seekhero)
1725 {
1726
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1727 return;
1728
1729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1730 {
1731 dmisc1 = e1tEACHTILE;
1732 FireWeapon();
1733 return;
1734 }
1735
1736 20952 float fire_angle=0.0;
1737 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1738
1739
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1740 {
1741 xoff += hxofs;
1742 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1743 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1744 else
1745 xoff += (hit_width / 2) - 8;
1746 }
1747
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1748 {
1749 yoff += hyofs;
1750 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1751 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1752 else
1753 yoff += (hit_height / 2) - 8;
1754 }
1755
1756
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1757 {
1758
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1759 {
1760 case down:
1761 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1762 3079 wx=x;
1763 3079 wy=y+8;
1764 3079 break;
1765
1766 case -1:
1767 case up:
1768 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1769 3297 wx=x;
1770 3297 wy=y-8;
1771 3297 break;
1772
1773 case left:
1774 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1775 5287 wx=x-8;
1776 5287 wy=y;
1777 5287 break;
1778
1779 case right:
1780 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1781 4208 wx=x+8;
1782 4208 wy=y;
1783 4208 break;
1784 }
1785
1786
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1787 {
1788
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1794
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1795
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1796 15735 }
1797 15871 }
1798 else
1799 {
1800 5081 wx = x;
1801 5081 wy = y;
1802 }
1803
1804
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1805 20952 sfx(wpnsfx(wpn),pan(x));
1806
1807 20952 int32_t i=Ewpns.Count()-1;
1808 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1809 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1810
1811
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1812 {
1813 7957 ew->angular=true;
1814 7957 ew->angle=fire_angle;
1815 7957 }
1816
1817
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1818 {
1819 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1821 20359 }
1822
1823
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1824 {
1825 766199 Ewpns.swap(j,j-1);
1826 766199 }
1827 20952 }
1828
1829 44662 void enemy::FireWeapon()
1830 {
1831 /*
1832 * Type:
1833 * 0x01: Boss fireball
1834 * 0x02: Seeks Hero
1835 * 0x04: Fast projectile
1836 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1837 */
1838
1839
2/2
✓ Branch 0 taken 44531 times.
✓ Branch 1 taken 131 times.
44662 if (wpn < 1) return;
1840
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44531 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1841 return;
1842
1843
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44531 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1844 dmisc1 = e1tEACHTILE;
1845
1846 44531 int32_t xoff = 0;
1847 44531 int32_t yoff = 0;
1848
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1849 {
1850 xoff += hxofs;
1851 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1852 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1853 else
1854 xoff += (hit_width / 2) - 8;
1855 }
1856
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1857 {
1858 yoff += hyofs;
1859 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1860 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1861 else
1862 yoff += (hit_height / 2) - 8;
1863 }
1864
1865 // TODO(crash): check that .add succeeds.
1866
1867
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41532 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44531 switch(dmisc1)
1868 {
1869 case e1t5SHOTS: //BS-Aquamentus
1870 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1871 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1872 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1873 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1874
1875 [[fallthrough]];
1876 case e1t3SHOTSFAST:
1877 case e1t3SHOTS: //Aquamentus
1878
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1879 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1880
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1881 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1882
1883 [[fallthrough]];
1884 default:
1885
12/20
✓ Branch 0 taken 42178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42173 times.
✓ Branch 12 taken 42178 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23940 times.
✓ Branch 16 taken 42178 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42178 times.
✗ Branch 19 not taken.
42178 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1886 42178 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887 42178 sfx(wpnsfx(wpn),pan(x));
1888 42178 break;
1889
1890 case e1tSLANT:
1891 {
1892 416 int32_t slant = 0;
1893
1894
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1895 246 slant = left;
1896
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1897 117 slant = right;
1898
1899
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1900 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1901 330 sfx(wpnsfx(wpn),pan(x));
1902 330 break;
1903 }
1904
1905 case e1t8SHOTS: //Fire Wizzrobe
1906
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1907 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1909
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1912
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1915
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1916 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1918
1919 [[fallthrough]];
1920 case e1t4SHOTS: //Stalfos 3
1921
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1922 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1923 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1924
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1931 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933 1937 sfx(wpnsfx(wpn),pan(x));
1934 1937 break;
1935
1936 case e1tSUMMON: // Bat Wizzrobe
1937 {
1938 if(dmisc4==0) break; // Summon 0
1939
1940 int32_t bc=0;
1941
1942 for(int32_t gc=0; gc<guys.Count(); gc++)
1943 {
1944 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1945 {
1946 ++bc;
1947 }
1948 }
1949
1950 if(bc<=40) // Not too many enemies
1951 {
1952 int32_t kids = guys.Count();
1953 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1954
1955 for(int32_t i=0; i<bats; i++)
1956 {
1957 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1958 {
1959 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1960 }
1961 }
1962
1963 sfx(firesfx, pan(x));
1964 }
1965
1966 break;
1967 }
1968
1969 case e1tSUMMONLAYER: // Summoner
1970 {
1971 if(count_layer_enemies(screen_spawned)==0)
1972 {
1973 break;
1974 }
1975
1976 int32_t kids = guys.Count();
1977
1978 if(kids<40)
1979 {
1980 int32_t newguys=(zc_oldrand()%3)+1;
1981 bool summoned=false;
1982
1983 for(int32_t i=0; i<newguys; i++)
1984 {
1985 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1986 int32_t x2=0;
1987 int32_t y2=0;
1988
1989 for(int32_t k=0; k<20; ++k)
1990 {
1991 x2=16*((zc_oldrand()%12)+2);
1992 y2=16*((zc_oldrand()%7)+2);
1993
1994 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1995 {
1996 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
1997 {
1998 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1999 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2000 {
2001 ((enemy*)guys.spr(kids+i))->fakez = 64;
2002 ((enemy*)guys.spr(kids+i))->z = 0;
2003 }
2004 }
2005
2006 summoned=true;
2007 break;
2008 }
2009 }
2010 }
2011
2012 if(summoned)
2013 {
2014 sfx(firesfx, pan(x));
2015 }
2016 }
2017
2018 break;
2019 }
2020 }
2021 44576 }
2022
2023
2024 // Hit the shield(s)?
2025 // Apparently, this function is only used for hookshots...
2026 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2027 {
2028
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2029 834 return false;
2030
2031 1933 bool ret = false;
2032
2033 // TODO: There must be some bitwise operations that can simplify this...
2034
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2035
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2036
2037
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2038
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2039
2040 1933 return ret;
2041 2767 }
2042
2043
2044 //! Weapon Editor for 2.6
2045 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2046
2047
2048 //converts a wqeapon ID to its defence index.
2049 127485 int32_t weaponToDefence(int32_t wid)
2050 {
2051
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64772 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4210 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127485 switch(wid)
2052 {
2053 case wNone: return -1;
2054 64772 case wSword: return edefSWORD;
2055 9439 case wBeam: return edefBEAM;
2056 25035 case wBrang: return edefBRANG;
2057 4210 case wBomb: return edefBOMB;
2058 37 case wSBomb: return edefSBOMB;
2059 48 case wLitBomb: return edefBOMB;
2060 case wLitSBomb: return edefSBOMB;
2061 3160 case wArrow: return edefARROW;
2062 9836 case wFire: return edefFIRE;
2063 case wWhistle:
2064 {
2065 return edefWhistle;
2066 }
2067 case wBait: return edefBAIT;
2068 269 case wWand: return edefWAND;
2069 1438 case wMagic: return edefMAGIC;
2070 case wCatching: return -1;
2071 case wWind: return edefWIND;
2072 512 case wRefMagic: return edefREFMAGIC;
2073 1459 case wRefFireball: return edefREFBALL;
2074 case wRefRock: return edefREFROCK;
2075 2054 case wHammer: return edefHAMMER;
2076 2767 case wHookshot: return edefHOOKSHOT;
2077 610 case wHSHandle: return edefHOOKSHOT;
2078 case wHSChain: return edefHOOKSHOT;
2079 240 case wSSparkle: return edefSPARKLE;
2080 469 case wFSparkle: return edefSPARKLE;
2081 case wSmack: return -1; // is this the candle object?
2082 case wPhantom: return -1; //engine created visual effects.
2083 case wCByrna: return edefBYRNA;
2084 19 case wRefBeam: return edefREFBEAM;
2085 case wStomp: return edefSTOMP;
2086 28 case wScript1: return edefSCRIPT01;
2087 case wScript2: return edefSCRIPT02;
2088 12 case wScript3: return edefSCRIPT03;
2089 77 case wScript4: return edefSCRIPT04;
2090 case wScript5: return edefSCRIPT05;
2091 case wScript6: return edefSCRIPT06;
2092 case wScript7: return edefSCRIPT07;
2093 case wScript8: return edefSCRIPT08;
2094 case wScript9: return edefSCRIPT09;
2095 993 case wScript10: return edefSCRIPT10;
2096 case wIce: return edefICE;
2097 case wSound: return edefSONIC;
2098 1 case wThrown: return edefTHROWN;
2099 case wRefArrow: return edefREFARROW;
2100 case wRefFire: return edefREFFIRE;
2101 case wRefFire2: return edefREFFIRE2;
2102 //case wPot: return edefPOT;
2103 // case wLitZap: return edefELECTRIC;
2104 // case wZ3Sword: return edefZ3SWORD;
2105 // case wLASWord: return edefLASWORD;
2106 // case wSpinAttk: return edefSPINATTK;
2107 // case wShield: return edefSHIELD;
2108 // case wTrowel: return edefTROWEL;
2109
2110 default: return -1;
2111 }
2112 127485 }
2113
2114 127485 int32_t getDefType(weapon *w)
2115 {
2116 127485 int32_t id = getWeaponID(w);
2117 127485 int32_t edef = weaponToDefence(id);
2118
2/2
✓ Branch 0 taken 124108 times.
✓ Branch 1 taken 3377 times.
127485 if(edef == edefHOOKSHOT)
2119 {
2120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2121 return edefSwitchHook;
2122 3377 }
2123 127485 return edef;
2124 127485 }
2125
2126 227168 int32_t getWeaponID(weapon *w)
2127 {
2128 227168 int32_t usewpn = w->useweapon;
2129
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226938 times.
227168 return (usewpn > 0) ? usewpn : w->id;
2130 }
2131
2132 127485 int32_t enemy::resolveEnemyDefence(weapon *w)
2133 {
2134 //sword edef is 9, but we're reading it at 0
2135 //,
2136 127485 int32_t weapondef = 0;
2137 127485 int32_t wdeftype = getDefType(w);
2138 127485 int32_t usedef = w->usedefense;
2139
2140
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127485 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2141 {
2142 weapondef = usedef*-1;
2143 }
2144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
127485 else if(unsigned(wdeftype) < edefLAST255)
2145 {
2146 127485 weapondef = wdeftype;
2147 127485 }
2148 127485 return weapondef;
2149 }
2150
2151 138054 byte get_def_ignrflag(int32_t edef)
2152 {
2153
3/3
✓ Branch 0 taken 115084 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138054 switch(edef)
2154 {
2155 case edIGNORE:
2156 case edIGNOREL1:
2157 case edSTUNORIGNORE:
2158 19287 return WPNUNB_IGNR;
2159 case edSTUNORCHINK:
2160 case edCHINK:
2161 case edCHINKL1:
2162 case edCHINKL2:
2163 case edCHINKL4:
2164 case edCHINKL6:
2165 case edCHINKL8:
2166 case edCHINKL10:
2167 case edLEVELCHINK2:
2168 case edLEVELCHINK3:
2169 case edLEVELCHINK4:
2170 case edLEVELCHINK5:
2171 3683 return WPNUNB_BLOCK;
2172 }
2173 115084 return 0;
2174 138054 }
2175
2176 138054 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2177 {
2178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138054 times.
138054 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2179 switch(edef)
2180 {
2181 case edIGNORE:
2182 case edIGNOREL1:
2183 case edCHINK:
2184 case edCHINKL1:
2185 case edCHINKL2:
2186 case edCHINKL4:
2187 case edCHINKL6:
2188 case edCHINKL8:
2189 case edCHINKL10:
2190 case edLEVELCHINK2:
2191 case edLEVELCHINK3:
2192 case edLEVELCHINK4:
2193 case edLEVELCHINK5:
2194 return edNORMAL;
2195 case edSTUNORIGNORE:
2196 case edSTUNORCHINK:
2197 return edSTUNONLY;
2198 }
2199 return edef;
2200 138054 }
2201
2202 // Do we do damage?
2203 // 0: takehit returns 0
2204 // 1: takehit returns 1
2205 // -1: do damage
2206 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2207 126492 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2208 {
2209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(switch_hooked) return 0;
2210 126492 int32_t tempx = x;
2211 126492 int32_t tempy = y;
2212 126492 int32_t the_defence = 0;
2213
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2214 {
2215 the_defence = edef*-1; //A specific defence type.
2216 }
2217 126492 else the_defence = defense[edef];
2218
2219 126492 the_defence = conv_edef_unblockable(the_defence, unblockable);
2220
2221
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119869 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126492 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2222 {
2223
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2224 {
2225 case edIGNORE:
2226 7 return 0;
2227 case edIGNOREL1:
2228 case edSTUNORIGNORE:
2229 if(*power <= 0)
2230 return 0;
2231 }
2232 6616 sfx(WAV_CHINK,pan(x));
2233 6616 return 1;
2234 }
2235
2236 119869 int32_t new_id = id;
2237 119869 int32_t effect_type = dmisc15;
2238 119869 int32_t delay_timer = 90;
2239 119869 enemy *gleeok = NULL;
2240 119869 enemy *ptra = NULL;
2241 119869 int32_t c = 0;
2242
2243
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93608 times.
119869 switch(the_defence)
2244 {
2245 case edREPLACE:
2246 {
2247 sclk = 0;
2248 if ( dmisc16 > 0 ) new_id = dmisc16;
2249 else new_id = id+1;
2250 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2251 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2252 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2253
2254 //Z_scripterrlog("new id is %d\n", new_id);
2255 switch(guysbuf[new_id&0xFFF].type)
2256 {
2257 //Fixme: possible enemy memory leak. (minor)
2258 case eeWALK:
2259 {
2260 enemy *e = new eStalfos(x,y,new_id,clk);
2261 guys.add(e);
2262 }
2263 break;
2264
2265 case eeLEV:
2266 {
2267 enemy *e = new eLeever(x,y,new_id,clk);
2268 guys.add(e);
2269 }
2270 break;
2271
2272 case eeTEK:
2273 {
2274 enemy *e = new eTektite(x,y,new_id,clk);
2275 guys.add(e);
2276 }
2277 break;
2278
2279 case eePEAHAT:
2280 {
2281 enemy *e = new ePeahat(x,y,new_id,clk);
2282 guys.add(e);
2283 }
2284 break;
2285
2286 case eeZORA:
2287 {
2288 enemy *e = new eZora(x,y,new_id,clk);
2289 guys.add(e);
2290 }
2291 break;
2292
2293 case eeGHINI:
2294 {
2295 enemy *e = new eGhini(x,y,new_id,clk);
2296 guys.add(e);
2297 }
2298 break;
2299
2300 case eeKEESE:
2301 {
2302 enemy *e = new eKeese(x,y,new_id,clk);
2303 guys.add(e);
2304 }
2305 break;
2306
2307 case eeWIZZ:
2308 {
2309 enemy *e = new eWizzrobe(x,y,new_id,clk);
2310 guys.add(e);
2311 }
2312 break;
2313
2314 case eePROJECTILE:
2315 {
2316 enemy *e = new eProjectile(x,y,new_id,clk);
2317 guys.add(e);
2318 }
2319 break;
2320
2321 case eeWALLM:
2322 {
2323 enemy *e = new eWallM(x,y,new_id,clk);
2324 guys.add(e);
2325 }
2326 break;
2327
2328 case eeAQUA:
2329 {
2330 enemy *e = new eAquamentus(x,y,new_id,clk);
2331 guys.add(e);
2332 e->x = x;
2333 e->y = y;
2334 }
2335 break;
2336
2337 case eeMOLD:
2338 {
2339 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2340 guys.add(e);
2341 e->x = x;
2342 e->y = y;
2343 }
2344 break;
2345
2346 case eeMANHAN:
2347 {
2348 enemy *e = new eManhandla(x,y,new_id,clk);
2349 guys.add(e);
2350 e->x = x;
2351 e->y = y;
2352 }
2353 break;
2354
2355 case eeGLEEOK:
2356 {
2357 *power = 0;
2358 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2359 guys.add(gleeok);
2360 // TODO(crash): check that .add succeeds.
2361 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2362 new_id &= 0xFFF;
2363 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2364 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2365 for(int32_t i=0; i<head_cnt; i++)
2366 {
2367 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2368 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2369 {
2370 al_trace("Gleeok head %d could not be created!\n",i+1);
2371
2372 for(int32_t j=0; j<i+1; j++)
2373 {
2374 guys.del(guys.Count()-1);
2375 }
2376
2377 break;
2378 }
2379 else
2380 {
2381 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2382 }
2383
2384 c-=guysbuf[new_id].attributes[3];
2385 }
2386 return 1;
2387 }
2388
2389 case eeGHOMA:
2390 {
2391 enemy *e = new eGohma(x,y,new_id,clk);
2392 guys.add(e);
2393 e->x = x;
2394 e->y = y;
2395 }
2396 break;
2397
2398 case eeLANM:
2399 {
2400 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2401 guys.add(e);
2402 e->x = x;
2403 e->y = y;
2404 }
2405 break;
2406
2407 case eeGANON:
2408 {
2409 enemy *e = new eGanon(x,y,new_id,clk);
2410 guys.add(e);
2411 e->x = x;
2412 e->y = y;
2413 }
2414 break;
2415
2416 case eeFAIRY:
2417 {
2418 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2419 guys.add(e);
2420 e->x = x;
2421 e->y = y;
2422 }
2423 break;
2424
2425 case eeFIRE:
2426 {
2427 enemy *e = new eFire(x,y,new_id,clk);
2428 guys.add(e);
2429 e->x = x;
2430 e->y = y;
2431 }
2432 break;
2433
2434 case eeOTHER:
2435 {
2436 enemy *e = new eOther(x,y,new_id,clk);
2437 guys.add(e);
2438 e->x = x;
2439 e->y = y;
2440 }
2441 break;
2442
2443 case eeSPINTILE:
2444 {
2445 enemy *e = new eSpinTile(x,y,new_id,clk);
2446 guys.add(e);
2447 e->x = x;
2448 e->y = y;
2449 }
2450 break;
2451
2452 // and these enemies use the misc10/misc2 value
2453 case eeROCK:
2454 {
2455 switch(guysbuf[new_id&0xFFF].attributes[9])
2456 {
2457 case 1:
2458 {
2459 enemy *e = new eBoulder(x,y,new_id,clk);
2460 guys.add(e);
2461 e->x = x;
2462 e->y = y;
2463 }
2464 break;
2465
2466 case 0:
2467 default:
2468 {
2469 enemy *e = new eRock(x,y,new_id,clk);
2470 guys.add(e);
2471 e->x = x;
2472 e->y = y;
2473 }
2474 break;
2475 }
2476
2477 break;
2478 }
2479
2480 case eeTRAP:
2481 {
2482 switch(guysbuf[new_id&0xFFF].attributes[1])
2483 {
2484 case 1:
2485 {
2486 enemy *e = new eTrap2(x,y,new_id,clk);
2487 guys.add(e);
2488 e->x = x;
2489 e->y = y;
2490 }
2491 break;
2492
2493 case 0:
2494 default:
2495 {
2496 enemy *e = new eTrap(x,y,new_id,clk);
2497 guys.add(e);
2498 e->x = x;
2499 e->y = y;
2500 }
2501 break;
2502 }
2503
2504 break;
2505 }
2506
2507 case eeDONGO:
2508 {
2509 switch(guysbuf[new_id&0xFFF].attributes[9])
2510 {
2511 case 1:
2512 {
2513 enemy *e = new eDodongo2(x,y,new_id,clk);
2514 guys.add(e);
2515 e->x = x;
2516 e->y = y;
2517 }
2518 break;
2519
2520 case 0:
2521 default:
2522 {
2523 enemy *e = new eDodongo(x,y,new_id,clk);
2524 guys.add(e);
2525 e->x = x;
2526 e->y = y;
2527 }
2528 break;
2529 }
2530
2531 break;
2532 }
2533
2534 case eeDIG:
2535 {
2536 switch(guysbuf[new_id&0xFFF].attributes[9])
2537 {
2538 case 1:
2539 {
2540 enemy *e = new eLilDig(x,y,new_id,clk);
2541 guys.add(e);
2542 e->x = x;
2543 e->y = y;
2544 }
2545 break;
2546
2547 case 0:
2548 default:
2549 {
2550 enemy *e = new eBigDig(x,y,new_id,clk);
2551 guys.add(e);
2552 e->x = x;
2553 e->y = y;
2554 }
2555 break;
2556 }
2557
2558 break;
2559 }
2560
2561 case eePATRA:
2562 {
2563 switch(guysbuf[new_id&0xFFF].attributes[9])
2564 {
2565 case 1:
2566 {
2567 if (get_qr(qr_HARDCODED_BS_PATRA))
2568 {
2569 enemy *e = new ePatraBS(x,y,new_id,clk);
2570 guys.add(e);
2571 e->x = x;
2572 e->y = y;
2573 break;
2574 }
2575 }
2576 [[fallthrough]];
2577 case 0:
2578 default:
2579 {
2580 enemy *e = new ePatra(x,y,new_id,clk);
2581 guys.add(e);
2582 e->x = x;
2583 e->y = y;
2584 }
2585 break;
2586 }
2587
2588 break;
2589 }
2590
2591 case eeGUY:
2592 {
2593 switch(guysbuf[new_id&0xFFF].attributes[9])
2594 {
2595 case 1:
2596 {
2597 enemy *e = new eTrigger(x,y,new_id,clk);
2598 guys.add(e);
2599 }
2600 break;
2601
2602 case 0:
2603 default:
2604 {
2605 enemy *e = new eNPC(x,y,new_id,clk);
2606 guys.add(e);
2607 }
2608 break;
2609 }
2610
2611 break;
2612 }
2613
2614 case eeSCRIPT01:
2615 case eeSCRIPT02:
2616 case eeSCRIPT03:
2617 case eeSCRIPT04:
2618 case eeSCRIPT05:
2619 case eeSCRIPT06:
2620 case eeSCRIPT07:
2621 case eeSCRIPT08:
2622 case eeSCRIPT09:
2623 case eeSCRIPT10:
2624 case eeSCRIPT11:
2625 case eeSCRIPT12:
2626 case eeSCRIPT13:
2627 case eeSCRIPT14:
2628 case eeSCRIPT15:
2629 case eeSCRIPT16:
2630 case eeSCRIPT17:
2631 case eeSCRIPT18:
2632 case eeSCRIPT19:
2633 case eeSCRIPT20:
2634 {
2635 enemy *e = new eScript(x,y,new_id,clk);
2636 guys.add(e);
2637 e->x = x;
2638 e->y = y;
2639 break;
2640 }
2641
2642
2643 case eeFFRIENDLY01:
2644 case eeFFRIENDLY02:
2645 case eeFFRIENDLY03:
2646 case eeFFRIENDLY04:
2647 case eeFFRIENDLY05:
2648 case eeFFRIENDLY06:
2649 case eeFFRIENDLY07:
2650 case eeFFRIENDLY08:
2651 case eeFFRIENDLY09:
2652 case eeFFRIENDLY10:
2653 {
2654 enemy *e = new eFriendly(x,y,new_id,clk);
2655 guys.add(e);
2656 e->x = x;
2657 e->y = y;
2658 break;
2659 }
2660
2661
2662 default: break;
2663 }
2664
2665 // add segments of segmented enemies
2666 int32_t c=0;
2667
2668 switch(guysbuf[new_id&0xFFF].type)
2669 {
2670 case eeMOLD:
2671 {
2672 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2673 new_id &= 0xFFF;
2674
2675 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2676 {
2677 //christ this is messy -DD
2678 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2679
2680 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2681 {
2682 al_trace("Moldorm segment %d could not be created!\n",i+1);
2683
2684 for(int32_t j=0; j<i+1; j++)
2685 guys.del(guys.Count()-1);
2686
2687 return 0;
2688 }
2689
2690 if(i>0)
2691 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2692
2693
2694 }
2695
2696 break;
2697 }
2698
2699 case eeLANM:
2700 {
2701 new_id &= 0xFFF;
2702 int32_t shft = guysbuf[new_id].attributes[1];
2703 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2704 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2705
2706 if(!guys.add(e))
2707 {
2708 al_trace("Lanmola segment 1 could not be created!\n");
2709 guys.del(guys.Count()-1);
2710 return 0;
2711 }
2712 e->x = x;
2713 e->y = y;
2714
2715
2716
2717 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2718 {
2719 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2720 if(!guys.add(e2))
2721 {
2722 al_trace("Lanmola segment %d could not be created!\n",i+1);
2723
2724 for(int32_t j=0; j<i+1; j++)
2725 guys.del(guys.Count()-1);
2726
2727 return 0;
2728 }
2729 e2->x = x;
2730 e2->y = y;
2731
2732 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2733
2734 }
2735 }
2736 break;
2737
2738 case eeMANHAN:
2739 new_id &= 0xFFF;
2740
2741 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2742 {
2743 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2744 {
2745 al_trace("Manhandla head %d could not be created!\n",i+1);
2746
2747 for(int32_t j=0; j<i+1; j++)
2748 {
2749 guys.del(guys.Count()-1);
2750 }
2751
2752 return 0;
2753 }
2754
2755
2756 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2757 }
2758
2759 break;
2760
2761 case eeGLEEOK:
2762 {
2763 /*
2764 new_id &= 0xFFF;
2765 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2766 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2767 for(int32_t i=0; i<head_cnt; i++)
2768 {
2769 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2770 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2771 {
2772 al_trace("Gleeok head %d could not be created!\n",i+1);
2773
2774 for(int32_t j=0; j<i+1; j++)
2775 {
2776 guys.del(guys.Count()-1);
2777 }
2778
2779 break;
2780 }
2781
2782 c-=guysbuf[new_id].misc4;
2783 */
2784
2785 // }
2786 }
2787 break;
2788
2789
2790 case eePATRA:
2791 {
2792 new_id &= 0xFFF;
2793 int32_t outeyes = 0;
2794 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2795
2796 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2797 {
2798 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2799 {
2800 al_trace("Patra outer eye %d could not be created!\n",i+1);
2801
2802 for(int32_t j=0; j<i+1; j++)
2803 guys.del(guys.Count()-1);
2804
2805 return 0;
2806 }
2807 else
2808 outeyes++;
2809
2810
2811 }
2812
2813 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2814 {
2815 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2816 {
2817 al_trace("Patra inner eye %d could not be created!\n",i+1);
2818
2819 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2820 guys.del(guys.Count()-1);
2821
2822 return 0;
2823 }
2824
2825
2826 }
2827 delete ptra;
2828 break;
2829 }
2830 }
2831
2832
2833 // TODO(crash): check that the above .add succeeded.
2834 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2835 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2836 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2837 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2838 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2839 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2840 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2841 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2842 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2843 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2844 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2845 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2846
2847
2848 item_set = 0; //Do not make a drop.
2849
2850 switch(effect_type)
2851 {
2852 case -7:
2853 {
2854 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2855 Lwpns.add(w);
2856 break;
2857 }
2858 case -6:
2859 {
2860 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2861 Lwpns.add(w);
2862 break;
2863 }
2864 case -5:
2865 {
2866 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2867 Lwpns.add(w);
2868 break;
2869 }
2870 case -4:
2871 {
2872 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2873 Lwpns.add(w);
2874 break;
2875 }
2876 case -3: explode(1); break;
2877 case -2: explode(2); break;
2878 case -1: explode(0); break;
2879 case 0: break;
2880
2881 default:
2882 {
2883 //Dummy weapon function
2884 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2885 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2886 Lwpns.add(w);
2887 break;
2888 }
2889 }
2890
2891
2892 yofs = -32768;
2893 switch(guysbuf[new_id&0xFFF].type)
2894 {
2895 case eeGLEEOK:
2896 {
2897 Z_scripterrlog("Replacing a gleeok.\n");
2898 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2899 hp = -999;
2900 if (tempenemy) tempenemy->hp = -999;
2901 break;
2902
2903 }
2904 default:
2905 hp = -1000; break;
2906 }
2907 int mi = mapind(cur_map, screen_spawned);
2908 ++game->guys[mi];
2909 return 1;
2910
2911 }
2912 case edSPLIT:
2913 {
2914 for ( int32_t q = 0; q < dmisc4; q++ )
2915 {
2916 addenemy(screen_spawned,x,y,
2917 dmisc3+0x1000,-15);
2918
2919 }
2920 item_set = 0; //Do not make a drop.
2921 hp = -1000;
2922 return -1;
2923
2924 }
2925 case edSUMMON:
2926 {
2927 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2928 for ( int32_t q = 0; q < summon_count; q++ )
2929 {
2930 int32_t x2=16*((zc_oldrand()%12)+2);
2931 int32_t y2=16*((zc_oldrand()%7)+2);
2932 addenemy(screen_spawned,
2933 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2934 x2,y2,
2935 dmisc3+0x1000,-15);
2936
2937 }
2938 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2939 return -1;
2940
2941 }
2942
2943 case edEXPLODESMALL:
2944 {
2945 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2946 Ewpns.add(ew);
2947 item_set = 0; //Should we make a drop?
2948 hp = -1000;
2949 return -1;
2950 }
2951
2952
2953 case edEXPLODEHARMLESS:
2954 {
2955 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2956 Ewpns.add(ew);
2957 ew->hyofs = -32768;
2958 item_set = 0; //Should we make a drop?
2959 hp = -1000;
2960 return -1;
2961 }
2962
2963
2964 case edEXPLODELARGE:
2965 {
2966 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2967 Ewpns.add(ew);
2968
2969 hp = -1000;
2970 return -1;
2971 }
2972
2973
2974 case edTRIGGERSECRETS:
2975 {
2976 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2977 return -1;
2978 }
2979
2980 case edSTUNORCHINK:
2981
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2982 {
2983 649 sfx(WAV_CHINK,pan(x));
2984 649 return 1;
2985 }
2986
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2987 {
2988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2989 return 0;
2990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2991 {
2992 sfx(WAV_CHINK,pan(x));
2993 return 1;
2994 }
2995 1119 }
2996 [[fallthrough]];
2997
2998 case edSTUNORIGNORE:
2999
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3000 955 return 0;
3001
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3002 {
3003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3004 return 0;
3005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3006 {
3007 sfx(WAV_CHINK,pan(x));
3008 return 1;
3009 }
3010 1952 }
3011 [[fallthrough]];
3012
3013 case edSTUNONLY:
3014
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3015 {
3016 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3017 321 return 1;
3018 }
3019
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3020 {
3021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3022 return 0;
3023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3024 {
3025 sfx(WAV_CHINK,pan(x));
3026 return 1;
3027 }
3028 3118 }
3029 4043 stunclk=160;
3030 4043 sfx(WAV_EHIT,pan(x));
3031 4043 return 1;
3032
3033 case edCHINKL1:
3034 if(*power >= 1*game->get_hero_dmgmult()) break;
3035 [[fallthrough]];
3036 case edCHINKL2:
3037
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINKL4:
3040
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3041 [[fallthrough]];
3042 case edCHINKL6:
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL8:
3046
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL10:
3049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINK:
3052 1056 sfx(WAV_CHINK,pan(x));
3053 1056 return 1;
3054
3055 case edIGNOREL1:
3056 if(*power > 0) break;
3057 [[fallthrough]];
3058
3059 case edIGNORE:
3060 17349 return 0;
3061
3062 case ed1HKO:
3063 492 *power = hp;
3064 492 return -3;
3065
3066 case ed2x:
3067 {
3068
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3069 //int32_t pow = *power;
3070 //*power = vbound((pow*2),0,214747);
3071 71 return -1;
3072 }
3073 case ed3x:
3074 {
3075 *power = zc_max(1,*power*3);
3076 //int32_t pow = *power;
3077 //*power = vbound((pow*3),0,214747);
3078 return -1;
3079 }
3080
3081 case ed4x:
3082 {
3083 *power = zc_max(1,*power*4);
3084 //int32_t pow = *power;
3085 //*power = vbound((pow*4),0,214747);
3086 return -1;
3087 }
3088
3089
3090 case edHEAL:
3091 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3092 //int32_t pow = *power;
3093 //*power = vbound((pow*-1),0,214747);
3094 //break;
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3096 158 return -1;
3097 }
3098 /*
3099 case edLEVELDAMAGE:
3100 {
3101 int32_t pow = *power;
3102 int32_t lvl = *level;
3103 *power = vbound((pow*lvl),0,214747);
3104 break;
3105 }
3106 case edLEVELREDUCTION:
3107 {
3108 int32_t pow = *power;
3109 int32_t lvl = *level;
3110 *power = vbound((pow/lvl),0,214747);
3111 break;
3112 }
3113 */
3114
3115 case edQUARTDAMAGE:
3116
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3117
3118 [[fallthrough]];
3119 case edHALFDAMAGE:
3120
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3121 988 break;
3122
3123 case edSWITCH:
3124 {
3125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3127 {
3128 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3129 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3130 return 0;
3131 }
3132 4 hooked_comborpos = rpos_t::None;
3133 4 hooked_layerbits = 0;
3134 4 switching_object = this;
3135 4 switch_hooked = true;
3136 4 Hero.doSwitchHook(game->get_switchhookstyle());
3137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3138 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3139 4 return 1;
3140 }
3141
3142 case 0:
3143 {
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93608 times.
93608 if(edef == edefSwitchHook)
3145 return -1;
3146
4/4
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74076 times.
✓ Branch 2 taken 7756 times.
✓ Branch 3 taken 11776 times.
93608 if (stunclk && *power == 0)
3147 {
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3149 return 0;
3150
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11750 times.
11776 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3151 {
3152 26 sfx(WAV_CHINK,pan(x));
3153 26 return 1;
3154 }
3155 11750 }
3156 93582 break;
3157 }
3158 }
3159
3160 94745 return -1;
3161 126492 }
3162
3163 126492 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3164 {
3165
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 int wuid = w?w->getUID():0;
3166
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3167
3168
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3169 Lwpns.add(w);
3170 126492 std::vector<int32_t> &ev = FFCore.eventData;
3171 126492 ev.clear();
3172 126492 ev.push_back(*power*10000);
3173 126492 ev.push_back(edef*10000);
3174 126492 ev.push_back(unblockable*10000);
3175 126492 ev.push_back(wpnId*10000);
3176 126492 ev.push_back(0);
3177 126492 ev.push_back(getUID());
3178 126492 ev.push_back(wuid);
3179
3180 126492 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3181 126492 *power = ev[0]/10000;
3182 126492 edef = ev[1]/10000;
3183 126492 unblockable = byte(ev[2]/10000);
3184 126492 wpnId = ev[3] / 10000;
3185 126492 bool nullify = ev[4]!=0;
3186 126492 ev.clear();
3187 126492 int ret = 0;
3188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(!nullify)
3189 {
3190 126492 ret = defendNew(wpnId, power, edef, unblockable);
3191
2/2
✓ Branch 0 taken 32388 times.
✓ Branch 1 taken 94104 times.
126492 if(ret < 0)
3192 {
3193 94104 ev.push_back(*power*10000);
3194 94104 ev.push_back(edef*10000);
3195 94104 ev.push_back(unblockable*10000);
3196 94104 ev.push_back(wpnId*10000);
3197 94104 ev.push_back(0);
3198 94104 ev.push_back(getUID());
3199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94104 times.
94104 ev.push_back(w?w->getUID():0);
3200
3201 94104 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3202 94104 *power = ev[0]/10000;
3203 94104 nullify = ev[4]!=0;
3204 94104 ev.clear();
3205 94104 }
3206 126492 }
3207
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3208 Lwpns.remove(w);
3209
3210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 return nullify ? 0 : ret;
3211 }
3212
3213 99683 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3214 {
3215
2/2
✓ Branch 0 taken 99106 times.
✓ Branch 1 taken 577 times.
99683 if(!realweap) realweap = w;
3216 99683 int32_t wid = getWeaponID(w);
3217
3218 99683 int32_t edef = resolveEnemyDefence(w);
3219
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 93415 times.
99683 if(QHeader.zelda_version > 0x250)
3220 6268 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3221
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3222 {
3223 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3224 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3225 993 return defend(wpnId, power, edefSCRIPT);
3226
3227 case wWhistle:
3228 return -1;
3229
3230 default:
3231 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3232 }
3233 99683 }
3234
3235
3236 // Check defenses without actually acting on them.
3237 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3238 {
3239
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3240 {
3241 case edSTUNONLY:
3242 474 return false;
3243 case edSTUNORCHINK:
3244 case edCHINK:
3245 15409 return unblockable&WPNUNB_BLOCK;
3246 case edSTUNORIGNORE:
3247 case edIGNORE:
3248 11050 return unblockable&WPNUNB_IGNR;
3249
3250 case edIGNOREL1:
3251 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3252 case edCHINKL1:
3253 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3254
3255 case edCHINKL2:
3256 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3257
3258 case edCHINKL4:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3260
3261 case edCHINKL6:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3263
3264 case edCHINKL8:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3266 }
3267
3268 469 return true;
3269 27402 }
3270
3271 // Do we do damage?
3272 // 0: takehit returns 0
3273 // 1: takehit returns 1
3274 // -1: do damage
3275 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3276 {
3277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3278 {
3279 switch(defense[edef])
3280 {
3281 case edIGNORE:
3282 return 0;
3283 case edIGNOREL1:
3284 case edSTUNORIGNORE:
3285 if(*power <= 0)
3286 return 0;
3287 }
3288
3289 sfx(WAV_CHINK,pan(x));
3290 return 1;
3291 }
3292
3293
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3294 {
3295 case edSTUNORCHINK:
3296 if(*power <= 0)
3297 {
3298 sfx(WAV_CHINK,pan(x));
3299 return 1;
3300 }
3301
3302 [[fallthrough]];
3303 case edSTUNORIGNORE:
3304 if(*power <= 0)
3305 return 0;
3306
3307 [[fallthrough]];
3308 case edSTUNONLY:
3309 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3310 return 1;
3311
3312 stunclk=160;
3313 sfx(WAV_EHIT,pan(x));
3314 return 1;
3315
3316 case edFREEZE:
3317 frozenclock=-1;
3318 //sfx(WAV_FREEZE,pan(x));
3319 return 1;
3320
3321 case edCHINKL1:
3322 if(*power >= 1*game->get_hero_dmgmult()) break;
3323 [[fallthrough]];
3324 case edCHINKL2:
3325 if(*power >= 2*game->get_hero_dmgmult()) break;
3326 [[fallthrough]];
3327 case edCHINKL4:
3328 if(*power >= 4*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL6:
3331 if(*power >= 6*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL8:
3334 if(*power >= 8*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL10:
3337 if(*power >= 10*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINK:
3340 sfx(WAV_CHINK,pan(x));
3341 return 1;
3342 case edTRIGGERSECRETS:
3343 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3344 break;
3345
3346 case edIGNOREL1:
3347 if(*power > 0) break;
3348 [[fallthrough]];
3349 case edIGNORE:
3350 800 return 0;
3351
3352 case ed1HKO:
3353 *power = hp;
3354 return -3;
3355
3356 case ed2x:
3357 {
3358 *power = zc_max(1,*power*2);
3359 //int32_t pow = *power;
3360 //*power = vbound((pow*2),0,214747);
3361 return -1;
3362 }
3363 case ed3x:
3364 {
3365 *power = zc_max(1,*power*3);
3366 //int32_t pow = *power;
3367 //*power = vbound((pow*3),0,214747);
3368 return -1;
3369 }
3370
3371 case ed4x:
3372 {
3373 *power = zc_max(1,*power*4);
3374 //int32_t pow = *power;
3375 //*power = vbound((pow*4),0,214747);
3376 return -1;
3377 }
3378
3379
3380 case edHEAL:
3381 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3382 //int32_t pow = *power;
3383 //*power = vbound((pow*-1),0,214747);
3384 //break;
3385 *power = zc_min(0,*power*-1);
3386 return -1;
3387 }
3388 /*
3389 case edLEVELDAMAGE:
3390 {
3391 int32_t pow = *power;
3392 int32_t lvl = *level;
3393 *power = vbound((pow*lvl),0,214747);
3394 break;
3395 }
3396 case edLEVELREDUCTION:
3397 {
3398 int32_t pow = *power;
3399 int32_t lvl = *level;
3400 *power = vbound((pow/lvl),0,214747);
3401 break;
3402 }
3403 */
3404
3405
3406 case edQUARTDAMAGE:
3407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3408
3409 [[fallthrough]];
3410 case edHALFDAMAGE:
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3412 7 break;
3413 }
3414
3415 193 return -1;
3416 993 }
3417
3418 // Defend against a particular item class.
3419 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3420 {
3421 int32_t def=-1;
3422
3423 switch(wpnId)
3424 {
3425 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3426 case wBrang:
3427 def = defend(wpnId, power, edefBRANG);
3428 break;
3429
3430 case wHookshot:
3431 def = defend(wpnId, power, edefHOOKSHOT);
3432 break;
3433
3434 // Anyway...
3435 case wBomb:
3436 def = defend(wpnId, power, edefBOMB);
3437 break;
3438
3439 case wSBomb:
3440 def = defend(wpnId, power, edefSBOMB);
3441 break;
3442
3443 case wArrow:
3444 def = defend(wpnId, power, edefARROW);
3445 break;
3446
3447 case wFire:
3448 def = defend(wpnId, power, edefFIRE);
3449 break;
3450
3451 case wWand:
3452 def = defend(wpnId, power, edefWAND);
3453 break;
3454
3455 case wMagic:
3456 def = defend(wpnId, power, edefMAGIC);
3457 break;
3458
3459 case wHammer:
3460 def = defend(wpnId, power, edefHAMMER);
3461 break;
3462
3463 case wSword:
3464 def = defend(wpnId, power, edefSWORD);
3465 break;
3466
3467 case wBeam:
3468 def = defend(wpnId, power, edefBEAM);
3469 break;
3470
3471 case wRefBeam:
3472 def = defend(wpnId, power, edefREFBEAM);
3473 break;
3474
3475 case wRefMagic:
3476 def = defend(wpnId, power, edefREFMAGIC);
3477 break;
3478
3479 case wRefFireball:
3480 def = defend(wpnId, power, edefREFBALL);
3481 break;
3482
3483 case wRefRock:
3484 def = defend(wpnId, power, edefREFROCK);
3485 break;
3486
3487 case wStomp:
3488 def = defend(wpnId, power, edefSTOMP);
3489 break;
3490
3491 case wCByrna:
3492 def = defend(wpnId, power, edefBYRNA);
3493 break;
3494
3495 case wScript1:
3496 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3497 else def = defend(wpnId, power, edefSCRIPT);
3498 break;
3499
3500 case wScript2:
3501 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3502 else def = defend(wpnId, power, edefSCRIPT);
3503 break;
3504
3505 case wScript3:
3506 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3507 else def = defend(wpnId, power, edefSCRIPT);
3508 break;
3509
3510 case wScript4:
3511 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3512 else def = defend(wpnId, power, edefSCRIPT);
3513 break;
3514
3515 case wScript5:
3516 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3517 else def = defend(wpnId, power, edefSCRIPT);
3518 break;
3519
3520 case wScript6:
3521 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3522 else def = defend(wpnId, power, edefSCRIPT);
3523 break;
3524
3525 case wScript7:
3526 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3527 else def = defend(wpnId, power, edefSCRIPT);
3528 break;
3529
3530 case wScript8:
3531 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3532 else def = defend(wpnId, power, edefSCRIPT);
3533 break;
3534
3535 case wScript9:
3536 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3537 else def = defend(wpnId, power, edefSCRIPT);
3538 break;
3539
3540 case wScript10:
3541 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3542 else def = defend(wpnId, power, edefSCRIPT);
3543 break;
3544
3545 case wWhistle:
3546 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3547 else break;
3548 break;
3549
3550 case wRefArrow:
3551 def = defend(wpnId, power, edefREFARROW);
3552 break;
3553 case wRefFire:
3554 def = defend(wpnId, power, edefREFFIRE);
3555 break;
3556 case wRefFire2:
3557 def = defend(wpnId, power, edefREFFIRE2);
3558 break;
3559
3560 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3561 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3562 //of the ten if the quest version is lower than N.
3563 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3564 //such as bool UseSeparatedScriptDefences. hah.
3565 default:
3566 //if(wpnId>=wScript1 && wpnId<=wScript10)
3567 // {
3568 // def = defend(wpnId, power, edefSCRIPT);
3569 // }
3570 // }
3571
3572 break;
3573 }
3574
3575 return def;
3576 }
3577
3578 // take damage or ignore it
3579 // 2 or -2: force wait a frame
3580 // < 0: damage (if any) dealt
3581 // > 0: blocked
3582 // 0: weapon passes through unhindered
3583 265281 int32_t enemy::takehit(weapon *w, weapon* realweap)
3584 {
3585
2/4
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265281 times.
265281 if(fallclk||drownclk) return 0;
3586
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 195507 times.
265281 if(!realweap) realweap = w;
3587 265281 int32_t wpnId = w->id;
3588 265281 int32_t power = w->power;
3589 265281 int32_t wpnx = w->x;
3590 265281 int32_t wpny = w->y;
3591 265281 int32_t enemyHitWeapon = w->parentitem;
3592 int32_t wpnDir;
3593 265281 int32_t parent_item = w->parentitem;
3594
3595
2/2
✓ Branch 0 taken 265166 times.
✓ Branch 1 taken 115 times.
265281 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3596 {
3597 115 wpnId = w->useweapon;
3598 115 }
3599
3600 // If it's a boomerang that just bounced, use the opposite direction;
3601 // otherwise, it might bypass a shield. This probably won't handle
3602 // every case correctly, but it's better than having shields simply
3603 // not work against boomerangs.
3604
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240200 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265281 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3605 11056 wpnDir = oppositeDir[w->dir];
3606 else
3607 254225 wpnDir = w->dir;
3608
3609
5/8
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8040 times.
✓ Branch 7 taken 272607 times.
265281 if(dying || clk<0 || hclk>0 || superman)
3610 8040 return 0;
3611
3612 //Prevent boomerang from writing to hitby[] for more than one frame.
3613 //This also prevents stunlock.
3614 //if ( stunclk > 0 ) return 0;
3615 //this needs a rule for boomerangs that cannot stunlock!
3616 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3617 //sigh.
3618
3619 272607 int32_t ret = -1;
3620
3621 // This obscure quest rule...
3622
5/6
✓ Branch 0 taken 92333 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 88830 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88830 times.
272607 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3623 {
3624 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3625 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3626 3503 wpnDir=zc_oldrand()&3;
3627
3628
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3629 {
3630 189 wpnDir=down;
3631 189 }
3632
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3633 {
3634 285 wpnDir=right;
3635 285 }
3636
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3637 {
3638 2064 wpnDir=up;
3639 2064 }
3640 else
3641 {
3642 965 wpnDir=left;
3643 }
3644 3503 }
3645
3646 272607 int32_t xdir = dir;
3647 272607 shieldCanBlock=false;
3648
3649
4/4
✓ Branch 0 taken 261327 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258560 times.
273369 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3650
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247920 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247812 times.
261327 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3651
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246793 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 246031 times.
247812 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3652 )
3653 // The hammer should already be dealt with by subclasses (Walker etc.)
3654 {
3655
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3656 {
3657 // Weapons which shields protect against
3658 case wSword:
3659 case wWand:
3660
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3661 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3662
3663 [[fallthrough]];
3664 case wHookshot:
3665 case wHSHandle:
3666 case wBrang:
3667 6184 shieldCanBlock=true;
3668 6522 break;
3669
3670 case wBeam:
3671 case wRefBeam:
3672 // Mirror shielded enemies!
3673 #if 0
3674 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3675 {
3676 if(wpnId>wEnemyWeapons)
3677 return 0;
3678
3679 sfx(WAV_CHINK,pan(x));
3680 return 1;
3681 }
3682
3683 #endif
3684
3685 [[fallthrough]];
3686 case wRefRock:
3687 case wRefFireball:
3688 case wMagic:
3689 #if 0
3690 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3691 {
3692 sfx(WAV_CHINK,pan(x));
3693 return 3;
3694 }
3695
3696 #endif
3697
3698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3699 return 0;
3700
3701 [[fallthrough]];
3702 case wArrow:
3703 382 case wRefArrow:
3704 default:
3705 1870 shieldCanBlock=true;
3706 1870 break;
3707
3708 // Bombs
3709 case wSBomb:
3710 case wBomb:
3711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3712 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3713 {
3714 sfx(WAV_CHINK,pan(x));
3715 return 0;
3716 }
3717 else break;
3718
3719 // Weapons which ignore shields
3720 case wWhistle:
3721 case wHammer:
3722 153 break;
3723
3724 // Weapons which shouldn't be removed by shields
3725 case wLitBomb:
3726 case wLitSBomb:
3727 case wWind:
3728 case wPhantom:
3729 case wSSparkle:
3730 case wBait:
3731 864 return 0;
3732
3733 case wFire:
3734 case wRefFire:
3735 case wRefFire2:
3736 ;
3737 680 }
3738 8887 }
3739
3740
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 98026 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266198 switch(wpnId)
3741 {
3742 case wWhistle: //No longer completely ignore whistle weapons! -Z
3743 {
3744
3745
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3746 {
3747 423 return 0; break;
3748 }
3749 else
3750 {
3751 w->power = power = itemsbuf[parent_item].misc5;
3752
3753 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3754
3755 if(def <= 0)
3756 {
3757 hp -= power;
3758 return def;
3759 }
3760 break;
3761 }
3762 break;
3763 }
3764
3765 case wPhantom:
3766 270 return 0;
3767
3768 case wLitBomb:
3769 case wLitSBomb:
3770 case wBait:
3771 case wWind:
3772 case wSSparkle:
3773 103219 return 0;
3774
3775 case wFSparkle:
3776
3777 // Only take sparkle damage if the sparkle's parent item is not
3778 // defended against.
3779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3780 {
3781 27402 int32_t p = 0;
3782 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3783
3784
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3785 {
3786 case itype_arrow:
3787 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3788
3789 break;
3790
3791 case itype_cbyrna:
3792 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3793
3794 break;
3795
3796 case itype_brang:
3797
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3798
3799 469 break;
3800
3801 default:
3802 return 0;
3803 }
3804 469 }
3805
3806 469 wpnId = wSword;
3807 469 power = game->get_hero_dmgmult()>>1;
3808 469 goto fsparkle;
3809 break;
3810
3811 case wBrang:
3812 {
3813 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3814 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3815 //preventing stunlock might be best, here. -Z
3816
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3817 19564 ret = def;
3818
3819 // Not hurt by 0-damage weapons
3820
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3821 {
3822 16380 stunclk=160;
3823
3824
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3825 {
3826
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3827 1311 goto hitclock;
3828 }
3829
3830 15069 break;
3831 }
3832
3833
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3834
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3835 else
3836 391 hp-=power;
3837
3838 3184 goto hitclock;
3839 }
3840
3841 case wHookshot:
3842 {
3843 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3844 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3845
3846
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3847 1773 ret = def;
3848
3849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3850
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3851 {
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3853 1625 stunclk=160;
3854
3855
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3856 {
3857
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3858 549 goto hitclock;
3859 }
3860
3861 1076 break;
3862 }
3863
3864
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3865 else
3866 45 hp-=power;
3867
3868 148 goto hitclock;
3869 }
3870 break;
3871
3872 case wHSHandle:
3873 {
3874
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3875 523 return 0;
3876
3877
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3879
3880 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3881
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3882
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3883 2177 return 0;
3884
3885 12102 power = game->get_hero_dmgmult();
3886 12571 }
3887
3888 fsparkle:
3889
3890 [[fallthrough]];
3891 default:
3892 // Work out the defenses!
3893 {
3894 99105 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3895
3896
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72539 times.
99105 if(def >= 0)
3897 26566 return def;
3898
2/2
✓ Branch 0 taken 72079 times.
✓ Branch 1 taken 460 times.
72539 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3899 460 ret = 0;
3900 }
3901
3902
2/2
✓ Branch 0 taken 72537 times.
✓ Branch 1 taken 2 times.
145078 if(!power)
3903 {
3904
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3905 2 hp-=1;
3906 else
3907 {
3908 // Don't make a long chain of 'stun' hits
3909 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3910 return 1;
3911
3912
3913 if(!switch_hooked)
3914 stunclk=160;
3915 break;
3916 }
3917 2 }
3918 72537 else hp-=power;
3919
3920 hitclock:
3921 77742 hclk=33;
3922
3923 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3924
2/2
✓ Branch 0 taken 34732 times.
✓ Branch 1 taken 43010 times.
77742 if((dir&2)==(w->dir&2))
3925 {
3926 43010 sclk=(w->dir<<8)+16;
3927 43010 }
3928 77742 }
3929
3930
5/6
✓ Branch 0 taken 74323 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21982 times.
✓ Branch 3 taken 71905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21982 times.
93887 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3931 {
3932 21982 fading=fade_blue_poof;
3933 21982 }
3934
3935
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 5285 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93887 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3936 {
3937
1/2
✓ Branch 0 taken 7632 times.
✗ Branch 1 not taken.
7632 if( hitsfx > 0 ) //user-set hit sound.
3938 {
3939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7632 times.
7632 if (!dying) //don't play the hit sound on death! -Z
3940 7632 sfx(hitsfx, pan(x));
3941 7632 }
3942 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3943 7632 }
3944 else //2.50.2 or earlier
3945 {
3946 86255 sfx(WAV_EHIT, pan(x));
3947 86255 sfx(hitsfx, pan(x));
3948 }
3949
2/2
✓ Branch 0 taken 93858 times.
✓ Branch 1 taken 29 times.
93887 if(type==eeGUY)
3950 29 sfx(WAV_EDEAD, pan(x));
3951
3952 // Penetrating weapons
3953
4/4
✓ Branch 0 taken 92013 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85107 times.
✓ Branch 3 taken 8780 times.
93887 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3954 {
3955 8780 int32_t item=enemyHitWeapon;
3956
3957
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7168 times.
8780 if(wpnId==wArrow)
3958 {
3959 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3960
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3961 379 return 0;
3962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3963 //if(item<0)
3964 else
3965 1233 item=current_item_id(itype_arrow);
3966 1233 }
3967
3968 else
3969 {
3970
3971 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3972
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3973 return 0;
3974
3975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3976 else
3977 //if(item<0)
3978 7168 item=current_item_id(itype_sword);
3979 }
3980 8401 }
3981
3982 93508 return ret;
3983 269367 }
3984
3985 61890611 bool enemy::dont_draw()
3986 {
3987
6/6
✓ Branch 0 taken 61426098 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61355191 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61251090 times.
61890611 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3988 639521 return true;
3989
3990
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59879265 times.
61251090 if(flags&guy_invisible)
3991 1371825 return true;
3992
3993
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59878833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59879265 if(flags&guy_lens_only && !lensclk)
3994 return true;
3995
3996 59879265 return false;
3997 61890611 }
3998
3999 #define DRAW_NORMAL 2
4000 #define DRAW_CLOAKED 1
4001 #define DRAW_INVIS 0
4002 // base drawing function to be used by all derived classes instead of
4003 // sprite::draw()
4004 44971115 void enemy::draw(BITMAP *dest)
4005 {
4006 44971115 didScriptThisFrame = false; //Since there's no better place to put it
4007
6/6
✓ Branch 0 taken 44205983 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44123333 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43888452 times.
44971115 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4008 1082663 return;
4009
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41120787 times.
43888452 if(flags&guy_invisible)
4010 2767665 return;
4011
4012 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4013 // be cloaked if they have "invisible displays as cloaked" checked.
4014
4015 41120787 byte canSee = DRAW_NORMAL;
4016 //Enemy specific stuff
4017
2/2
✓ Branch 0 taken 41119623 times.
✓ Branch 1 taken 1164 times.
41120787 if ( editorflags & ENEMY_FLAG1 )
4018 {
4019 1164 canSee = DRAW_INVIS;
4020
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4021
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4022 {
4023 if (game->item[dmisc13])
4024 {
4025 canSee = DRAW_NORMAL;
4026 }
4027 //else if ( lensclk && getlensid.flags SHOWINVIS )
4028 //{
4029 //
4030 //}
4031 //else
4032 //{
4033 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4034 // //otherwisem invisible
4035 //}
4036 }
4037 1164 }
4038 //Room specific
4039 41120787 mapscr* scr = get_scr(screen_spawned);
4040
2/2
✓ Branch 0 taken 38949588 times.
✓ Branch 1 taken 2171199 times.
41120787 if (scr->flags3&fINVISROOM)
4041 {
4042
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4044 2171199 }
4045 //Lens check
4046
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41093250 times.
41120787 if (lensclk)
4047 {
4048
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4049 {
4050
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4051 432 }
4052 27537 }
4053 else
4054 {
4055
2/2
✓ Branch 0 taken 41019834 times.
✓ Branch 1 taken 73416 times.
41093250 if(flags&guy_lens_only)
4056 73416 canSee = DRAW_INVIS;
4057 }
4058
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41046207 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4059
3/4
✓ Branch 0 taken 40820203 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40820203 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4060
4061
2/2
✓ Branch 0 taken 41046207 times.
✓ Branch 1 taken 74580 times.
41120787 if (canSee == DRAW_INVIS)
4062 74580 return;
4063
4064
4/4
✓ Branch 0 taken 41043832 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41043825 times.
41046207 if(fallclk||drownclk)
4065 {
4066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4067 {
4068 sprite::drawcloaked(dest);
4069 }
4070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4071 {
4072 2382 sprite::draw(dest);
4073 2382 }
4074 2382 return;
4075 }
4076 41043825 int32_t cshold=cs;
4077
4078
2/2
✓ Branch 0 taken 904261 times.
✓ Branch 1 taken 40139564 times.
41043825 if(dying)
4079 {
4080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if(clk2>=19)
4081 {
4082 if(!(clk2&2))
4083 {
4084 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4085 if (canSee == DRAW_CLOAKED)
4086 {
4087 sprite::drawcloaked(dest);
4088 }
4089 else if (canSee == DRAW_NORMAL)
4090 {
4091 sprite::draw(dest);
4092 }
4093 }
4094 return;
4095 }
4096
4097 904261 flip = 0;
4098 904261 tile = wpnsbuf[spr_death].tile;
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if ( do_animation )
4100 {
4101 904261 int32_t offs = 0;
4102
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4103 {
4104
2/2
✓ Branch 0 taken 49521 times.
✓ Branch 1 taken 1628 times.
51149 if(clk2 > 2)
4105 {
4106 1628 spr_death_anim_clk=0;
4107 1628 clk2=1;
4108
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1614 times.
1628 if(hp > -1000)
4109 1614 death_sfx();
4110 1628 }
4111
4/4
✓ Branch 0 taken 38450 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38048 times.
51149 if(clk2==1 && spr_death_anim_clk>-1)
4112 {
4113 38048 ++clk2;
4114
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
38048 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4115
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38027 times.
38048 spr_death_anim_frm *= zc_max(1,txsz);
4116 38048 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4117
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37972 times.
38048 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4118
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38046 times.
✓ Branch 4 taken 36438 times.
✓ Branch 5 taken 1610 times.
38048 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4119 {
4120 1610 spr_death_anim_clk=-1;
4121 1610 clk2=1;
4122 1610 }
4123 38048 }
4124 51149 tile += spr_death_anim_frm;
4125 51149 }
4126
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4127 {
4128
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4129 315607 }
4130
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4131 {
4132 179336 offs = 1;
4133 179336 }
4134
4135
2/2
✓ Branch 0 taken 455768 times.
✓ Branch 1 taken 448493 times.
904261 if(offs)
4136 {
4137
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4138 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4139
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4140 448493 }
4141 904261 tile += offs;
4142 904261 }
4143
4144
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4145 555938 cs = wpnsbuf[spr_death].csets&15;
4146 else
4147 348323 cs = (((clk2+5)>>1)&3)+6;
4148 904261 }
4149
3/4
✓ Branch 0 taken 1204162 times.
✓ Branch 1 taken 38935402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204162 times.
40139564 else if(hclk>0 && getCanFlicker())
4150 {
4151 1204162 cs = getFlashingCSet();
4152 1204162 }
4153 //draw every other frame for flickering enemies
4154
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40795794 times.
41043825 if (is_hitflickerframe(false))
4155 {
4156
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4157
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4158 {
4159 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4160 sprite_flicker_color = temp_flicker_color;
4161 sprite::draw(dest);
4162 }
4163 248031 }
4164 else
4165 {
4166
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40570632 times.
40795794 if (canSee == DRAW_CLOAKED)
4167 {
4168 225162 sprite::drawcloaked(dest);
4169 225162 }
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40570632 times.
40570632 else if (canSee == DRAW_NORMAL)
4171 {
4172
1/2
✓ Branch 0 taken 40570632 times.
✗ Branch 1 not taken.
40570632 if ( frozenclock < 0 )
4173 {
4174 if ( frozentile > 0 ) tile = frozentile;
4175 loadpalset(csBOSS,frozencset);
4176 }
4177 40570632 sprite::draw(dest);
4178 40570632 }
4179 }
4180 41043825 cs=cshold;
4181 44971115 }
4182
4183 //old zc bosses
4184 40943259 void enemy::drawzcboss(BITMAP *dest)
4185 {
4186 40943259 didScriptThisFrame = false; //Since there's no better place to put it
4187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40943259 times.
40943259 if(dont_draw())
4188 return;
4189
4190 40943259 int32_t cshold=cs;
4191
4192
2/2
✓ Branch 0 taken 784038 times.
✓ Branch 1 taken 40159221 times.
40943259 if(dying)
4193 {
4194
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780078 times.
784038 if(clk2>=19)
4195 {
4196
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4197 1980 sprite::drawzcboss(dest);
4198
4199 3960 return;
4200 }
4201
4202 780078 flip = 0;
4203 780078 tile = wpnsbuf[spr_death].tile;
4204
4205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780078 times.
780078 if ( do_animation )
4206 {
4207
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4208 {
4209
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4210 {
4211 6 spr_death_anim_clk=0;
4212 6 clk2=1;
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4214 6 death_sfx();
4215 6 }
4216
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4217 {
4218 76 ++clk2;
4219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4221 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4223
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4224 {
4225 2 spr_death_anim_clk=-1;
4226 2 clk2=1;
4227 2 }
4228 76 }
4229 4516 tile += spr_death_anim_frm;
4230 4516 }
4231
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4232
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4233
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4234 165743 ++tile;
4235 780078 }
4236
4237
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4238 466974 cs = wpnsbuf[spr_death].csets&15;
4239 else
4240 313104 cs = (((clk2+5)>>1)&3)+6;
4241 780078 }
4242
2/2
✓ Branch 0 taken 38944531 times.
✓ Branch 1 taken 1214690 times.
40159221 else if(hclk>0)
4243 {
4244 1214690 cs = getFlashingCSet();
4245 1214690 }
4246
4247 40939299 mapscr* scr = get_scr(screen_spawned);
4248
4249
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38893680 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40946842 if((scr->flags3&fINVISROOM) &&
4250
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4252 7543 lensclk) && type!=eeGANON)
4253 {
4254 7543 sprite::drawcloaked(dest);
4255 7543 }
4256 else
4257 {
4258
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40908283 times.
40931756 if (is_hitflickerframe(true))
4259 {
4260
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4261
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4262 {
4263 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4264 sprite_flicker_color = temp_flicker_color;
4265 sprite::drawzcboss(dest);
4266 }
4267 23473 }
4268 else
4269 40908283 sprite::drawzcboss(dest);
4270 }
4271
4272 40939299 cs=cshold;
4273 40943259 }
4274
4275
4276 // similar to the overblock function--can do up to a 32x32 sprite
4277 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4278 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4279 {
4280 323235 int32_t thold=tile;
4281 323235 int32_t t1=tile;
4282 323235 int32_t t2=tile+20;
4283 323235 int32_t t3=tile+1;
4284 323235 int32_t t4=tile+21;
4285
4286
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4287 {
4288 case 1:
4289 enemy::drawzcboss(dest);
4290 break;
4291
4292 case 3:
4293 if(flip&2)
4294 zc_swap(t1,t2);
4295
4296 tile=t1;
4297 enemy::drawzcboss(dest);
4298 tile=t2;
4299 yofs+=16;
4300 enemy::drawzcboss(dest);
4301 yofs-=16;
4302 break;
4303
4304 case 5:
4305 t2=tile+1;
4306
4307 if(flip&1)
4308 zc_swap(t1,t2);
4309
4310 tile=t1;
4311 enemy::drawzcboss(dest);
4312 tile=t2;
4313 xofs+=16;
4314 enemy::drawzcboss(dest);
4315 xofs-=16;
4316 break;
4317
4318 case 15:
4319
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4320 {
4321 6756 zc_swap(t1,t3);
4322 6756 zc_swap(t2,t4);
4323 6756 }
4324
4325
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4326 {
4327 zc_swap(t1,t2);
4328 zc_swap(t3,t4);
4329 }
4330
4331 323235 tile=t1;
4332 323235 enemy::drawzcboss(dest);
4333 323235 tile=t2;
4334 323235 yofs+=16;
4335 323235 enemy::drawzcboss(dest);
4336 323235 yofs-=16;
4337 323235 tile=t3;
4338 323235 xofs+=16;
4339 323235 enemy::drawzcboss(dest);
4340 323235 tile=t4;
4341 323235 yofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 xofs-=16;
4344 323235 yofs-=16;
4345 323235 break;
4346 }
4347
4348 323235 tile=thold;
4349 323235 }
4350
4351 20383527 void enemy::drawshadow(BITMAP *dest, bool translucent)
4352 {
4353
4/4
✓ Branch 0 taken 18372181 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17845263 times.
20383527 if(dont_draw() || isSideViewGravity())
4354 {
4355 2538264 return;
4356 }
4357
4358
2/2
✓ Branch 0 taken 327632 times.
✓ Branch 1 taken 17517631 times.
17845263 if(dying)
4359 {
4360 327632 return;
4361 }
4362
4363 17517631 mapscr* scr = get_scr(screen_spawned);
4364
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799382 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170621 times.
17517631 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4365 17517631 (darkroom))
4366 {
4367 347010 return;
4368 }
4369 else
4370 {
4371
4/4
✓ Branch 0 taken 16571466 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 16523997 times.
✓ Branch 3 taken 47469 times.
17170621 if(enemycanfall(id, false) && shadowtile == 0)
4372 47469 shadowtile = wpnsbuf[spr_shadow].tile;
4373
4374
5/6
✓ Branch 0 taken 16226739 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15627584 times.
✓ Branch 5 taken 599155 times.
17170621 if(z>0 || fakez>0 || !enemycanfall(id, false))
4375 {
4376
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542762 times.
1543037 if(!shadow_overpit(this))
4377 1542762 sprite::drawshadow(dest,translucent);
4378 1543037 }
4379 }
4380 20383527 }
4381
4382 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4383 {
4384 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4385
4386
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4387 {
4388 129181 xofs-=mx;
4389 129181 yofs-=my;
4390 129181 enemy::draw(sub);
4391 129181 xofs+=mx;
4392 129181 yofs+=my;
4393 129181 destroy_bitmap(sub);
4394 129181 }
4395 else
4396 enemy::draw(dest);
4397 129181 }
4398
4399 9 void enemy::init_size_flags()
4400 {
4401
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4402
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4403
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4404
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4406
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4407
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4408
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4409
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4410 {
4411 yofs = (int32_t)d->yofs;
4412 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4413 }
4414
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4415 9 }
4416
4417 // override hit detection to check for invicibility, stunned, etc
4418 112664439 bool enemy::hit()
4419 {
4420
4/4
✓ Branch 0 taken 111337172 times.
✓ Branch 1 taken 1327267 times.
✓ Branch 2 taken 109522516 times.
✓ Branch 3 taken 1814656 times.
112664439 if(dying || hclk>0) return false;
4421 109522516 return sprite::hit();
4422 112664439 }
4423 730351 bool enemy::hit(sprite *s)
4424 {
4425
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4426 713374 return sprite::hit(s);
4427 730351 }
4428
4429 44723304 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4430 {
4431
2/2
✓ Branch 0 taken 3973386 times.
✓ Branch 1 taken 40749918 times.
44723304 if(!hit()) return false;
4432 40749918 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4433 44723304 }
4434 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4435 {
4436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4437 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4438 78011 }
4439
4440 11190904 bool enemy::hit(weapon *w)
4441 {
4442
2/2
✓ Branch 0 taken 1196298 times.
✓ Branch 1 taken 9994606 times.
11190904 if(!hit()) return false;
4443
4444
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3347224 times.
9994606 if (replay_version_check(0, 14))
4445 {
4446
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4447 225051 return false;
4448 6422331 return sprite::hit(w);
4449 }
4450 3347224 return w->hit(this);
4451 11190904 }
4452
4453 38124564 bool enemy::can_pitfall(bool checkspawning)
4454 {
4455
4/4
✓ Branch 0 taken 36552358 times.
✓ Branch 1 taken 1572206 times.
✓ Branch 2 taken 36539384 times.
✓ Branch 3 taken 1585180 times.
38124564 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4456
2/2
✓ Branch 0 taken 29877757 times.
✓ Branch 1 taken 6661627 times.
36539384 switch(guysbuf[id&0xFFF].type)
4457 {
4458 case eeAQUA:
4459 case eeDIG:
4460 case eeDONGO:
4461 case eeFAIRY:
4462 case eeGANON:
4463 case eeGHOMA:
4464 case eeGLEEOK:
4465 case eeGUY:
4466 case eeLANM:
4467 case eeMANHAN:
4468 case eeMOLD:
4469 case eeNONE:
4470 case eePATRA:
4471 case eeZORA:
4472 6661627 return false; //Disallowed types
4473 default:
4474 29877757 return true;
4475 }
4476 38124564 }
4477 //Handle death
4478 38009335 void enemy::try_death(bool force_kill)
4479 {
4480
8/8
✓ Branch 0 taken 37952766 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37952755 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43653 times.
✓ Branch 5 taken 37909102 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43652 times.
38009335 if(!dying && (force_kill || (hp<=0 && !immortal)))
4481 {
4482 43663 std::vector<int32_t> &ev = FFCore.eventData;
4483 43663 ev.clear();
4484 43663 ev.push_back(10000);
4485 43663 ev.push_back(getUID());
4486
4487 43663 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4488 43663 bool isSaved = !ev[0];
4489 43663 ev.clear();
4490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43663 times.
43663 if(isSaved) return;
4491
4492
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43613 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43663 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4493 {
4494
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4495 {
4496
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4497 {
4498
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4499 {
4500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4501 {
4502 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4503 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4504 }
4505 else
4506 {
4507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4508 {
4509 items.spr(i)->x = x+(txsz-1)*8;
4510 items.spr(i)->y = y-2+(tysz-1)*8;
4511 }
4512 else
4513 {
4514 3 items.spr(i)->x = x;
4515 3 items.spr(i)->y = y - 2;
4516 }
4517 }
4518 3 items.spr(i)->z = z;
4519 3 items.spr(i)->fakez = fakez;
4520 3 }
4521 else
4522 {
4523 41 items.spr(i)->x = x;
4524 41 items.spr(i)->y = y - 2;
4525 }
4526 44 }
4527 51 }
4528 44 }
4529
4530 43663 dying=true;
4531
4532
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43631 times.
43663 if(fading==fade_flash_die)
4533 32 clk2=19+18*4;
4534 else
4535 {
4536 43631 clk2 = BSZ ? 15 : 19;
4537
4538
2/2
✓ Branch 0 taken 21062 times.
✓ Branch 1 taken 22569 times.
43631 if(fading!=fade_blue_poof)
4539 22569 fading=0;
4540 }
4541
4542
2/2
✓ Branch 0 taken 43613 times.
✓ Branch 1 taken 50 times.
43663 if(itemguy)
4543 {
4544 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4545 50 item_set=0;
4546 50 }
4547
6/6
✓ Branch 0 taken 42609 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33920 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32492 times.
43663 if (screen_spawned < 128 && count_enemy && !script_spawned)
4548 32492 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4549 43663 }
4550 38009335 }
4551
4552 // --==**==--
4553
4554 // Movement routines that can be used by derived classes as needed
4555
4556 // --==**==--
4557
4558 556554 void enemy::fix_coords(bool bound)
4559 {
4560
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4561
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if(moveflags & move_ignore_screenedge) bound = false;
4562
4563
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474874 times.
556554 if(bound)
4564 {
4565 474874 int w = world_w;
4566 474874 int h = world_h;
4567
4568
1/2
✓ Branch 0 taken 474874 times.
✗ Branch 1 not taken.
474874 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4569 {
4570
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4571
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4572 474874 }
4573 else
4574 {
4575 x=vbound(x, 0, w-16);
4576 y=vbound(y, 0, h-16);
4577 }
4578 474874 }
4579
4580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556554 times.
556554 if(!OUTOFBOUNDS(id, x, y))
4581 {
4582 556554 do_fix(x, 16, true);
4583
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555415 times.
556554 if(isSideViewGravity())
4584 1139 do_fix(y,8,true);
4585 555415 else do_fix(y,16,true);
4586 556554 }
4587 556554 }
4588 9176 bool enemy::cannotpenetrate()
4589 {
4590
4/4
✓ Branch 0 taken 8995 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8957 times.
9176 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4591 }
4592
4593 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4594 {
4595 bool ok;
4596 562 int32_t dx = 0, dy = 0;
4597 562 int32_t sv = 8;
4598
4599 //Why is this here??? Why is it needed???
4600 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4601
4602
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4603 {
4604 case 8:
4605 case up:
4606
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4607 return false;
4608
4609 69 dy = dy1-s;
4610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4612 69 break;
4613
4614 case 12:
4615 case down:
4616
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4617 return false;
4618
4619 51 dy = dy2+s;
4620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4621 51 break;
4622
4623 case 14:
4624 case left:
4625 47 dx = dx1-s;
4626 47 sv = ((isSideViewGravity())?7:8);
4627
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4628
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4629 47 break;
4630
4631 case 10:
4632 case right:
4633 85 dx = dx2+s;
4634 85 sv = ((isSideViewGravity())?7:8);
4635
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4636 85 break;
4637
4638 case 9:
4639 case r_up:
4640 94 dx = dx2+s;
4641 94 dy = dy1-s;
4642
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4644 94 break;
4645
4646 case 11:
4647 case r_down:
4648 78 dx = dx2+s;
4649 78 dx = dy2+s;
4650
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4652 78 break;
4653
4654 case 13:
4655 case l_down:
4656 57 dx = dx1-s;
4657 57 dy = dy2+s;
4658
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4660 57 break;
4661
4662 case 15:
4663 case l_up:
4664 81 dx = dx1-s;
4665 81 dy = dy1-s;
4666
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4668 81 break;
4669
4670 default:
4671 db=99;
4672 return true;
4673 }
4674
4675 562 return ok;
4676 562 }
4677
4678
4679
4680
4681 // returns true if next step is ok, false if there is something there
4682 7360028 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4683 {
4684 7360028 bool ok = false; //initialise the var, son't just declare it
4685 7360028 int32_t dx = 0, dy = 0;
4686 7360028 int32_t sv = 8;
4687 7360028 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4688 //Why is this here??? Why is it needed???
4689 7360028 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4692
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4693
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4694 7360028 bool offgrid = OFFGRID_ENEMY;
4695
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352737 times.
7360028 if(!offgrid)
4696 {
4697 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4698
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usehei<16)usehei=16;
4699
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usewid<16)usewid=16;
4700 7352737 }
4701
9/9
✓ Branch 0 taken 1331317 times.
✓ Branch 1 taken 1107763 times.
✓ Branch 2 taken 1227757 times.
✓ Branch 3 taken 1218339 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119676 times.
7360028 switch(ndir) //need to check every 8 pixels between two points
4702 {
4703 case 8:
4704 case up:
4705 {
4706
4/4
✓ Branch 0 taken 150808 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150148 times.
✓ Branch 3 taken 660 times.
1331317 if(enemycanfall(id) && isSideViewGravity())
4707 660 return false;
4708
4709 1330657 dy = dy1-s;
4710
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330177 times.
1330657 special = (special==spw_clipbottomright)?spw_none:special;
4711 1330657 tries = usewid/(offgrid ? 8 : 16);
4712
4713
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 1331307 times.
2461744 for ( ; tries > 0; --tries )
4714 {
4715
2/2
✓ Branch 0 taken 197596 times.
✓ Branch 1 taken 1133711 times.
1331307 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4716 1331307 try_x += (offgrid ? 8 : 16);
4717
2/2
✓ Branch 0 taken 1131087 times.
✓ Branch 1 taken 200220 times.
1331307 if (!ok) break;
4718 1131087 }
4719
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 200220 times.
1330657 if(!ok) break;
4720
1/2
✓ Branch 0 taken 1130437 times.
✗ Branch 1 not taken.
1130437 if((usewid%16)>0) //Uneven width
4721 {
4722 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4723 }
4724 1130437 break;
4725 }
4726 case 12:
4727 case down:
4728 {
4729
4/4
✓ Branch 0 taken 180701 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179975 times.
✓ Branch 3 taken 726 times.
1107763 if(enemycanfall(id) && isSideViewGravity())
4730 726 return false;
4731
4732 1107037 dy = dy2+s;
4733 1107037 tries = usewid/(offgrid ? 8 : 16);
4734
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 1107821 times.
2008465 for ( ; tries > 0; --tries )
4735 {
4736
3/4
✓ Branch 0 taken 205645 times.
✓ Branch 1 taken 902176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902176 times.
1107821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4737 1107821 try_x += (offgrid ? 8 : 16);
4738
2/2
✓ Branch 0 taken 901428 times.
✓ Branch 1 taken 206393 times.
1107821 if (!ok) break;
4739 901428 }
4740
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 206393 times.
1107037 if(!ok) break;
4741
1/2
✓ Branch 0 taken 900644 times.
✗ Branch 1 not taken.
900644 if((usewid%16)>0) //Uneven width
4742 {
4743 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4744 }
4745 900644 break;
4746 }
4747 case 14:
4748 case left:
4749 {
4750 1227757 dx = dx1-s;
4751 1227757 sv = ((isSideViewGravity())?7:0);
4752
4/4
✓ Branch 0 taken 1227134 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225366 times.
1227757 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4753 1227757 tries = usehei/(offgrid ? 8 : 16);
4754
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 1228674 times.
2257217 for ( ; tries > 0; --tries )
4755 {
4756
2/2
✓ Branch 0 taken 198029 times.
✓ Branch 1 taken 1030645 times.
1228674 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4757 1228674 try_y += (offgrid ? 8 : 16);
4758
2/2
✓ Branch 0 taken 1029460 times.
✓ Branch 1 taken 199214 times.
1228674 if (!ok) break;
4759 1029460 }
4760
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 199214 times.
1227757 if(!ok) break;
4761
1/2
✓ Branch 0 taken 1028543 times.
✗ Branch 1 not taken.
1028543 if((usehei%16)>0) //Uneven height
4762 {
4763 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4764 }
4765 1028543 break;
4766 }
4767 case 10:
4768 case right:
4769 {
4770 1218339 dx = dx2+s;
4771 1218339 sv = ((isSideViewGravity())?7:0);
4772 1218339 tries = usehei/(offgrid ? 8 : 16);
4773
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 1219233 times.
2249244 for ( ; tries > 0; --tries )
4774 {
4775
3/4
✓ Branch 0 taken 186973 times.
✓ Branch 1 taken 1032260 times.
✓ Branch 2 taken 1032260 times.
✗ Branch 3 not taken.
1219233 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4776 1219233 try_y += (offgrid ? 8 : 16);
4777
2/2
✓ Branch 0 taken 1030905 times.
✓ Branch 1 taken 188328 times.
1219233 if (!ok) break;
4778 1030905 }
4779
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 188328 times.
1218339 if(!ok) break;
4780
1/2
✓ Branch 0 taken 1030011 times.
✗ Branch 1 not taken.
1030011 if((usehei%16)>0) //Uneven height
4781 {
4782 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4783 }
4784 1030011 break;
4785 }
4786 case 9:
4787 case r_up:
4788 {
4789 540601 dx = dx2+s;
4790 540601 dy = dy1-s;
4791 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4792 540601 sv = ((isSideViewGravity())?7:0);
4793
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4794 {
4795 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4796 540601 try_y = 0;
4797
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4798 {
4799
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4800
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4801 540601 try_y += (offgrid ? 8 : 16);
4802
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4803 523541 }
4804
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4806 {
4807 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4808 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4809 }
4810 523541 try_x += (offgrid ? 8 : 16);
4811 523541 }
4812
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4813
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4814 {
4815 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4816 try_y = 0;
4817 for ( ; tries_y > 0; --tries_y )
4818 {
4819 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4820 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4821 try_y += (offgrid ? 8 : 16);
4822 if (!ok) break;
4823 }
4824 if (!ok) break;
4825 if((usehei%16)>0) //Uneven height
4826 {
4827 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4828 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4829 }
4830 }
4831 523541 break;
4832 }
4833 case 11:
4834 case r_down:
4835 {
4836 642269 dx = dx2+s;
4837 642269 dx = dy2+s;
4838 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4839 //sv = ((isSideViewGravity())?7:0);
4840
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4841 {
4842 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4843 642269 try_y = 0;
4844
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4845 {
4846
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4847
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4848 642269 try_y += (offgrid ? 8 : 16);
4849
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4850 626871 }
4851
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4853 {
4854 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4855 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4856 }
4857 626871 try_x += (offgrid ? 8 : 16);
4858 626871 }
4859
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4860
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4861 {
4862 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4863 try_y = 0;
4864 for ( ; tries_y > 0; --tries_y )
4865 {
4866 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4867 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4868 try_y += (offgrid ? 8 : 16);
4869 if (!ok) break;
4870 }
4871 if (!ok) break;
4872 if((usehei%16)>0) //Uneven height
4873 {
4874 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4875 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4876 }
4877 }
4878 626871 break;
4879 }
4880 case 13:
4881 case l_down:
4882 {
4883 603869 dx = dx1-s;
4884 603869 dy = dy2+s;
4885 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4886 //sv = ((isSideViewGravity())?7:0);
4887
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4888 {
4889 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4890 603869 try_y = 0;
4891
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4892 {
4893
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4894
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4895 603869 try_y += (offgrid ? 8 : 16);
4896
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4897 586793 }
4898
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4900 {
4901 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4902 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4903 }
4904 586793 try_x += (offgrid ? 8 : 16);
4905 586793 }
4906
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4907
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4908 {
4909 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4910 try_y = 0;
4911 for ( ; tries_y > 0; --tries_y )
4912 {
4913 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4914 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4915 try_y += (offgrid ? 8 : 16);
4916 if (!ok) break;
4917 }
4918 if (!ok) break;
4919 if((usehei%16)>0) //Uneven height
4920 {
4921 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4922 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4923 }
4924 }
4925 586793 break;
4926 }
4927 case 15:
4928 case l_up:
4929 {
4930 568437 dx = dx1-s;
4931 568437 dy = dy1-s;
4932 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4933 568437 sv = ((isSideViewGravity())?7:0);
4934
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4935 {
4936 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4937 568437 try_y = 0;
4938
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4939 {
4940
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4941
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4942 568437 try_y += (offgrid ? 8 : 16);
4943
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4944 552494 }
4945
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4947 {
4948 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4949 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4950 }
4951 552494 try_x += (offgrid ? 8 : 16);
4952 552494 }
4953
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4954
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4955 {
4956 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4957 try_y = 0;
4958 for ( ; tries_y > 0; --tries_y )
4959 {
4960 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4961 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4962 try_y += (offgrid ? 8 : 16);
4963 if (!ok) break;
4964 }
4965 if (!ok) break;
4966 if((usehei%16)>0) //Uneven height
4967 {
4968 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4969 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4970 }
4971 }
4972 552494 break;
4973 }
4974 default:
4975 119676 db=99;
4976 119676 return true;
4977 }
4978
4979 7238966 return ok;
4980 7360028 }
4981
4982
4983 4652348 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4984 {
4985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4987
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4988
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4989 4652348 --usewid;
4990 4652348 --usehei;
4991 4652348 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4992 }
4993
4994 1244902 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4995 {
4996 1244902 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
4997
4998
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1238083 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244902 if(special==spw_clipright&&ndir==right)
4999 {
5000 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5001 1798 }
5002
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5003
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5004
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5005
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5006 1244902 --usewid;
5007 1244902 --usehei;
5008
2/2
✓ Branch 0 taken 717873 times.
✓ Branch 1 taken 527029 times.
1244902 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5009 }
5010
5011 136347 bool enemy::canmove(int32_t ndir, bool kb)
5012 {
5013 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5014 }
5015
5016 // 8-directional
5017 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5018 {
5019 562 int32_t ndir=0;
5020
5021 // can move straight, check if it wants to turn
5022
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5023 {
5024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5025 {
5026 int32_t w = Lwpns.idFirst(wBait);
5027
5028 if(w>=0)
5029 {
5030 int32_t bx = Lwpns.spr(w)->x;
5031 int32_t by = Lwpns.spr(w)->y;
5032
5033 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5034
5035 if(abs(int32_t(y)-by)>14)
5036 {
5037 if(ndir>0) // Already left or right
5038 {
5039 // Making the diagonal directions
5040 ndir += (by<y) ? 2 : 4;
5041 }
5042 else
5043 {
5044 ndir = (by<y) ? up : down;
5045 }
5046 }
5047
5048 if(canmove(ndir,special,false))
5049 {
5050 dir=ndir;
5051 return;
5052 }
5053 }
5054 }
5055
5056 // Homing added.
5057
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5058 {
5059 ndir = lined_up(8,true);
5060
5061 if(ndir>=0 && canmove(ndir,special,false))
5062 {
5063 dir=ndir;
5064 }
5065
5066 return;
5067 }
5068
5069 549 int32_t r=zc_oldrand();
5070
5071
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5072 {
5073 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5074 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5075
5076
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5077 525 dir=ndir;
5078
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5079 19 dir=ndir2;
5080
5081
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5082 // due to numerous lost fractional components. -L
5083 {
5084 x.doFloor();
5085 y.doFloor();
5086 }
5087 549 }
5088
5089 549 return;
5090 }
5091
5092 // can't move straight, must turn
5093 13 int32_t i=0;
5094
5095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5096 {
5097 20 ndir=(zc_oldrand()&7)+8;
5098
5099
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5100 13 break;
5101 7 }
5102
5103
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5104 {
5105 for(ndir=8; ndir<16; ndir++)
5106 {
5107 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5108 goto ok;
5109 }
5110
5111 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5112 }
5113
5114 ok:
5115 13 dir=ndir;
5116 13 x.doFloor();
5117 13 y.doFloor();
5118 562 }
5119
5120 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5121 {
5122 580728 int32_t ndir=0;
5123
5124 // can move straight, check if it wants to turn
5125
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5126 {
5127
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5128 {
5129 101 int32_t i = Lwpns.idFirst(wBait);
5130
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5131 {
5132 weapon *w = (weapon*)Lwpns.spr(i);
5133 if (get_qr(qr_FIND_CLOSEST_BAIT))
5134 {
5135 int32_t currentrange;
5136 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5137 else currentrange = -1;
5138 int curid = i;
5139 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5140 for(; i<Lwpns.Count(); ++i)
5141 {
5142 weapon *lw = (weapon*)Lwpns.spr(i);
5143 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5144 {
5145 currentrange = distance(x, y, lw->x, lw->y);
5146 curid = i;
5147 }
5148 }
5149 i = curid;
5150 if (currentrange == -1) i = -1;
5151 }
5152 else
5153 {
5154 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5155 }
5156 if(i>=0)
5157 {
5158 int32_t bx = Lwpns.spr(i)->x;
5159 int32_t by = Lwpns.spr(i)->y;
5160
5161 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5162
5163 if(abs(int32_t(y)-by)>14)
5164 {
5165 if(ndir>0) // Already left or right
5166 {
5167 // Making the diagonal directions
5168 ndir += (by<y) ? 2 : 4;
5169 }
5170 else
5171 {
5172 ndir = (by<y) ? up : down;
5173 }
5174 }
5175 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5176 if(canmove(ndir,special,false))
5177 {
5178 dir=ndir;
5179 return;
5180 }
5181 }
5182 }
5183 101 }
5184
5185 // Homing added.
5186
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5187 {
5188 14216 ndir = lined_up(8,true);
5189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5190
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5191 {
5192 5852 dir=ndir;
5193 5852 }
5194
5195 14216 return;
5196 }
5197
5198 533849 int32_t r=zc_oldrand();
5199
5200
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5201 {
5202 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5203 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5204
5205
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5206 154477 dir=ndir;
5207
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5208 4947 dir=ndir2;
5209
5210
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5211 // due to numerous lost fractional components. -L
5212 {
5213 7326 x.doFloor();
5214 7326 y.doFloor();
5215 7326 }
5216 160281 }
5217
5218 533849 return;
5219 }
5220
5221 // can't move straight, must turn
5222 32663 int32_t i=0;
5223
5224 // TODO: speed this up!
5225
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5226 {
5227 61154 ndir=(zc_oldrand()&7)+8;
5228
5229
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5230 32593 break;
5231 28561 }
5232
5233
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5234 {
5235
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5236 {
5237
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5238 17 goto ok;
5239 444 }
5240
5241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5242 53 }
5243
5244 ok:
5245 32663 dir=ndir;
5246 32663 x.doFloor();
5247 32663 y.doFloor();
5248 580728 }
5249
5250 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5251 {
5252 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5253 574253 }
5254
5255 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5256 {
5257 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5258 562 }
5259
5260 // makes the enemy slide backwards when hit
5261 // sclk: first byte is clk, second byte is dir
5262 // makes the enemy slide backwards when hit
5263 // sclk: first byte is clk, second byte is dir
5264 15646054 int32_t enemy::slide()
5265 {
5266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15646054 times.
15646054 if(script_knockback_clk!=0) //scripted knockback
5267 {
5268 sclk = 0;
5269 return 1; //scripted knockback ran
5270 }
5271
5/6
✓ Branch 0 taken 102113 times.
✓ Branch 1 taken 15543941 times.
✓ Branch 2 taken 7857 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7857 times.
15646054 if(sclk==0 || (hp<=0 && !immortal))
5272 15551798 return 0;
5273
5274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5275 {
5276 sclk = 0;
5277 if(!OFFGRID_ENEMY)
5278 {
5279 //Fix to grid
5280 do_fix(x, 16, true);
5281 do_fix(y, 16, true);
5282 }
5283 return 0;
5284 }
5285
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5286 {
5287 2153 sclk=0;
5288 2153 return 0;
5289 }
5290
5291 92103 --sclk;
5292
5293
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5294 {
5295 case up:
5296 {
5297
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5298 {
5299 7 sclk=0;
5300 7 return 0;
5301 }
5302
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5303
5304 10357 break;
5305 }
5306 case down:
5307 {
5308
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5309 {
5310 2 sclk=0;
5311 2 return 0;
5312 }
5313
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5314
5315 12143 break;
5316 }
5317 case left:
5318 {
5319
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5320 {
5321 13 sclk=0;
5322 13 return 0;
5323 }
5324
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5325
5326 31483 break;
5327 }
5328 case right:
5329 {
5330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5331 {
5332 sclk=0;
5333 return 0;
5334 }
5335
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5336 35484 break;
5337 }
5338 }
5339
5340 91252 int32_t move = knockbackSpeed;
5341
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5342 {
5343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5344 91252 move -= thismove;
5345 91252 hitdir = (sclk>>8);
5346
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5347 {
5348 case up:
5349 10357 y-=thismove;
5350 10357 break;
5351
5352 case down:
5353 12143 y+=thismove;
5354 12143 break;
5355
5356 case left:
5357 31483 x-=thismove;
5358 31483 break;
5359
5360 case right:
5361 35484 x+=thismove;
5362 35484 break;
5363 }
5364
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5365 {
5366
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5367 {
5368 case up:
5369 case down:
5370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5371 y = 0;
5372
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5373 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5374 else
5375 1648 y = TRUNCATE_TILE(int32_t(y));
5376
5377 1973 break;
5378
5379 case left:
5380 case right:
5381
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5382 4 x = 0;
5383
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5384 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5385 else
5386 2069 x = TRUNCATE_TILE(int32_t(x));
5387
5388 2906 break;
5389 }
5390
5391 4883 sclk=0;
5392 4883 clk3=0;
5393 4883 break;
5394 }
5395 }
5396
5397
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5398 {
5399 //hitdir = -1;
5400 7363 sclk=0;
5401 7363 }
5402 91252 return 2;
5403 15646054 }
5404
5405 bool enemy::can_slide()
5406 {
5407 if(sclk==0 || (hp<=0 && !immortal))
5408 return false;
5409
5410 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5411 {
5412 return false;
5413 }
5414
5415 return true;
5416 }
5417
5418 bool enemy::fslide()
5419 {
5420 if(sclk==0 || (hp<=0 && !immortal))
5421 return false;
5422
5423 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5424 {
5425 sclk=0;
5426 return false;
5427 }
5428
5429 --sclk;
5430
5431 switch(sclk>>8)
5432 {
5433 case up:
5434 if(y<=16)
5435 {
5436 sclk=0;
5437 return false;
5438 }
5439
5440 break;
5441
5442 case down:
5443 if(y>=world_h-16)
5444 {
5445 sclk=0;
5446 return false;
5447 }
5448
5449 break;
5450
5451 case left:
5452 if(x<=16)
5453 {
5454 sclk=0;
5455 return false;
5456 }
5457
5458 break;
5459
5460 case right:
5461 if(x>=world_w-16)
5462 {
5463 sclk=0;
5464 return false;
5465 }
5466
5467 break;
5468 }
5469 hitdir = (sclk>>8);
5470 switch(sclk>>8)
5471 {
5472 case up:
5473 y-=4;
5474 break;
5475
5476 case down:
5477 y+=4;
5478 break;
5479
5480 case left:
5481 x-=4;
5482 break;
5483
5484 case right:
5485 x+=4;
5486 break;
5487 }
5488
5489 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5490 {
5491 switch(sclk>>8)
5492 {
5493 case up:
5494 case down:
5495 if((int32_t(y)&15) > 7)
5496 y = TRUNCATE_TILE(int32_t(y)) + 16;
5497 else
5498 y = TRUNCATE_TILE(int32_t(y));
5499
5500 break;
5501
5502 case left:
5503 case right:
5504 if((int32_t(x)&15) > 7)
5505 x = TRUNCATE_TILE(int32_t(x)) + 16;
5506 else
5507 x = TRUNCATE_TILE(int32_t(x));
5508
5509 break;
5510 }
5511
5512 sclk=0;
5513 clk3=0;
5514 }
5515
5516 if((sclk&255)==0)
5517 sclk=0;
5518
5519 return true;
5520 }
5521
5522 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5523 {
5524 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5525 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5526 bool ret = sprite::knockback(time, dir, speed);
5527 if(ret) sclk = 0; //kill engine knockback if interrupted
5528 //! Perhaps also set hitdir here, if needed for timing? -Z
5529 return ret;
5530 }
5531
5532 38009324 bool enemy::runKnockback()
5533 {
5534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if((script_knockback_clk&0xFF)==0)
5535 {
5536 38009324 script_knockback_clk = 0;
5537 38009324 return false;
5538 }
5539 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5540 {
5541 return false;
5542 }
5543 int32_t move = script_knockback_speed;
5544 int32_t kb_dir = script_knockback_clk>>8;
5545 --script_knockback_clk;
5546
5547 while(move>0)
5548 {
5549 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5550 move -= thismove;
5551 hitdir = kb_dir;
5552 switch(kb_dir)
5553 {
5554 case r_up:
5555 case l_up:
5556 case up:
5557 y-=thismove;
5558 break;
5559
5560 case r_down:
5561 case l_down:
5562 case down:
5563 y+=thismove;
5564 break;
5565 }
5566 switch(kb_dir)
5567 {
5568 case l_up:
5569 case l_down:
5570 case left:
5571 x-=thismove;
5572 break;
5573
5574 case r_up:
5575 case r_down:
5576 case right:
5577 x+=thismove;
5578 break;
5579 }
5580 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5581 {
5582 if(!canmove(kb_dir,(zfix)0,0,true))
5583 {
5584 script_knockback_clk=0;
5585 clk3=0;
5586 //Fix to grid
5587 switch(kb_dir)
5588 {
5589 case up:
5590 case down:
5591 break;
5592 default:
5593 if(x < 0)
5594 x = 0;
5595 else if((int32_t(x)&15) > 7)
5596 x = TRUNCATE_TILE(int32_t(x)) + 16;
5597 else
5598 x = TRUNCATE_TILE(int32_t(x));
5599 break;
5600 }
5601 switch(kb_dir)
5602 {
5603 case left:
5604 case right:
5605 break;
5606 default:
5607 if(y < 0)
5608 y = 0;
5609 else if((int32_t(y)&15) > 7)
5610 y = TRUNCATE_TILE(int32_t(y)) + 16;
5611 else
5612 y = TRUNCATE_TILE(int32_t(y));
5613 break;
5614 }
5615 break;
5616 }
5617 }
5618 else
5619 {
5620 if(!scr_canplace(x,y,0,true))
5621 {
5622 script_knockback_clk=0;
5623 clk3=0;
5624 //Fix to grid
5625 if (OFFGRID_ENEMY)
5626 {
5627 switch(kb_dir)
5628 {
5629 case up:
5630 case down:
5631 break;
5632 default:
5633 if(x < 0)
5634 x = 0;
5635 else if((int32_t(x)&7) > 3)
5636 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5637 else
5638 x = TRUNCATE_HALF_TILE(int32_t(x));
5639 break;
5640 }
5641 switch(kb_dir)
5642 {
5643 case left:
5644 case right:
5645 break;
5646 default:
5647 if(y < 0)
5648 y = 0;
5649 else if((int32_t(y)&7) > 3)
5650 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5651 else
5652 y = TRUNCATE_HALF_TILE(int32_t(y));
5653 break;
5654 }
5655 }
5656 else
5657 {
5658 switch(kb_dir)
5659 {
5660 case up:
5661 case down:
5662 break;
5663 default:
5664 if(x < 0)
5665 x = 0;
5666 else if((int32_t(x)&15) > 7)
5667 x = TRUNCATE_TILE(int32_t(x)) + 16;
5668 else
5669 x = TRUNCATE_TILE(int32_t(x));
5670 break;
5671 }
5672 switch(kb_dir)
5673 {
5674 case left:
5675 case right:
5676 break;
5677 default:
5678 if(y < 0)
5679 y = 0;
5680 else if((int32_t(y)&15) > 7)
5681 y = TRUNCATE_TILE(int32_t(y)) + 16;
5682 else
5683 y = TRUNCATE_TILE(int32_t(y));
5684 break;
5685 }
5686 }
5687 break;
5688 }
5689
5690 }
5691 }
5692 return true;
5693 38009324 }
5694 // changes enemy's direction, checking restrictions
5695 // rate: 0 = no random changes, 16 = always random change
5696 // homing: 0 = none, 256 = always
5697 // grumble 0 = none, 4 = strongest appetite
5698 521075 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5699 {
5700 521075 int32_t ndir=-1;
5701
5702
4/4
✓ Branch 0 taken 110060 times.
✓ Branch 1 taken 411015 times.
✓ Branch 2 taken 37882 times.
✓ Branch 3 taken 72178 times.
521075 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5703 {
5704 72178 int32_t i = Lwpns.idFirst(wBait);
5705
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5706 {
5707 weapon *w = (weapon*)Lwpns.spr(i);
5708 if (get_qr(qr_FIND_CLOSEST_BAIT))
5709 {
5710 int32_t currentrange;
5711 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5712 else currentrange = -1;
5713 int curid = i;
5714 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5715 for(; i<Lwpns.Count(); ++i)
5716 {
5717 weapon *lw = (weapon*)Lwpns.spr(i);
5718 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5719 {
5720 currentrange = distance(x, y, lw->x, lw->y);
5721 curid = i;
5722 }
5723 }
5724 i = curid;
5725 if (currentrange == -1) i = -1;
5726 }
5727 else
5728 {
5729 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5730 }
5731 if (i >= 0)
5732 {
5733 int32_t bx = Lwpns.spr(i)->x;
5734 int32_t by = Lwpns.spr(i)->y;
5735
5736 if(abs(int32_t(y)-by)>14)
5737 {
5738 ndir = (by<y) ? up : down;
5739 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5740 if(canmove(ndir,special,false))
5741 {
5742 dir=ndir;
5743 return;
5744 }
5745 }
5746
5747 ndir = (bx<x) ? left : right;
5748 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5749 if(canmove(ndir,special,false))
5750 {
5751 dir=ndir;
5752 return;
5753 }
5754 }
5755 }
5756 72178 }
5757
5758
2/2
✓ Branch 0 taken 352951 times.
✓ Branch 1 taken 168124 times.
521075 if((zc_oldrand()&255)<abs(newhoming))
5759 {
5760 168124 ndir = lined_up(8,false);
5761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168124 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5762
4/4
✓ Branch 0 taken 45390 times.
✓ Branch 1 taken 122734 times.
✓ Branch 2 taken 5720 times.
✓ Branch 3 taken 39670 times.
168124 if(ndir>=0 && canmove(ndir,special,false))
5763 {
5764 39670 dir=ndir;
5765 39670 return;
5766 }
5767 128454 }
5768
5769 481405 int32_t i=0;
5770
5771
2/2
✓ Branch 0 taken 3340 times.
✓ Branch 1 taken 1181128 times.
1184468 for(; i<32; i++)
5772 {
5773 1181128 int32_t r=zc_oldrand();
5774
5775
2/2
✓ Branch 0 taken 345129 times.
✓ Branch 1 taken 835999 times.
1181128 if((r&15)<newrate)
5776 345129 ndir=(r>>4)&3;
5777 else
5778 835999 ndir=dir;
5779
5780
2/2
✓ Branch 0 taken 703063 times.
✓ Branch 1 taken 478065 times.
1181128 if(canmove(ndir,special,false))
5781 478065 break;
5782 703063 }
5783
5784
2/2
✓ Branch 0 taken 478065 times.
✓ Branch 1 taken 3340 times.
482163 if(i==32)
5785 {
5786
2/2
✓ Branch 0 taken 8939 times.
✓ Branch 1 taken 758 times.
9697 for(ndir=0; ndir<4; ndir++)
5787 {
5788
2/2
✓ Branch 0 taken 6357 times.
✓ Branch 1 taken 2582 times.
8939 if(canmove(ndir,special,false))
5789 2582 goto ok;
5790 6357 }
5791
5792
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 698 times.
758 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5793 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5794 758 }
5795
5796 ok:
5797 481405 dir = ndir;
5798 521075 }
5799
5800 2682 void enemy::newdir()
5801 {
5802 2682 newdir(4,0,spw_none);
5803 2682 }
5804
5805 zfix enemy::distance_left()
5806 {
5807 int32_t a2=x.getInt();
5808 int32_t b2=y.getInt();
5809
5810 switch(dir)
5811 {
5812 case up:
5813 return (zfix)(b2&0xF);
5814
5815 case down:
5816 return (zfix)(16-(b2&0xF));
5817
5818 case left:
5819 return (zfix)(a2&0xF);
5820
5821 case right:
5822 return (zfix)(16-(a2&0xF));
5823 }
5824
5825 return (zfix)0;
5826 }
5827
5828 // keeps walking around
5829 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5830 {
5831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5832 return;
5833
5834
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5835 8261 return;
5836
5837
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5838 {
5839 26115 fix_coords(true);
5840 26115 newdir(newrate,newhoming,special);
5841
5842
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5843 clk3=0;
5844 else
5845 26115 clk3=int32_t(16.0/step);
5846 26115 }
5847
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5848 {
5849 45 dir^=1;
5850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5851 else clk3=32767;
5852 45 }
5853
5854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5855 383173 move(step);
5856 391434 }
5857
5858 void enemy::constant_walk()
5859 {
5860 constant_walk(4,0,spw_none);
5861 }
5862
5863 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5864 {
5865 35220 return (newy<<8)+newx;
5866 }
5867
5868 // for variable step rates
5869 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5870 {
5871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5872 return;
5873
5874
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5875 55444 return;
5876
5877 418370 zfix dx = (zfix)0;
5878 418370 zfix dy = (zfix)0;
5879
5880
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5881 {
5882 case 8:
5883 case up:
5884 93441 dy-=step;
5885 93441 break;
5886
5887 case 12:
5888 case down:
5889 97752 dy+=step;
5890 97752 break;
5891
5892 case 14:
5893 case left:
5894 111603 dx-=step;
5895 111603 break;
5896
5897 case 10:
5898 case right:
5899 113743 dx+=step;
5900 113743 break;
5901
5902 case 15:
5903 case l_up:
5904 dx-=step;
5905 dy-=step;
5906 break;
5907
5908 case 9:
5909 case r_up:
5910 dx+=step;
5911 dy-=step;
5912 break;
5913
5914 case 13:
5915 case l_down:
5916 dx-=step;
5917 dy+=step;
5918 break;
5919
5920 case 11:
5921 case r_down:
5922 dx+=step;
5923 dy+=step;
5924 break;
5925 }
5926
5927
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5928 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5929 {
5930 12443 fix_coords();
5931 12443 newdir(newrate,newhoming,special);
5932 12443 clk3=pos(x,y);
5933 12443 }
5934
5935 418370 move(step);
5936 473814 }
5937
5938 // pauses for a while after it makes a complete move (to a new square)
5939 12334139 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5940 {
5941
4/4
✓ Branch 0 taken 79892 times.
✓ Branch 1 taken 12254247 times.
✓ Branch 2 taken 67060 times.
✓ Branch 3 taken 12832 times.
12334139 if(sclk && clk2)
5942 {
5943 12832 clk3=0;
5944 12832 }
5945
5946
11/14
✓ Branch 0 taken 12261115 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12261115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12261115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11793947 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11656198 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11651662 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11651662 times.
12334139 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5947 {
5948 682477 return;
5949 }
5950
5951
2/2
✓ Branch 0 taken 2132955 times.
✓ Branch 1 taken 9518707 times.
11651662 if(clk2>0)
5952 {
5953 2132955 --clk2;
5954 2132955 return;
5955 }
5956
5957
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 9107463 times.
9518707 if(clk3<=0)
5958 {
5959 411244 fix_coords(true);
5960 411244 newdir(newrate,newhoming,special);
5961 411244 clk3=int32_t(16.0/step);
5962
2/2
✓ Branch 0 taken 411047 times.
✓ Branch 1 taken 197 times.
411244 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411244 times.
411244 if(clk2<0)
5964 {
5965 clk2=0;
5966 }
5967
2/2
✓ Branch 0 taken 54771 times.
✓ Branch 1 taken 356473 times.
411244 else if((zc_oldrand()&15)<newhrate)
5968 {
5969 54771 clk2=haltcnt;
5970 54771 return;
5971 }
5972 356473 }
5973
2/2
✓ Branch 0 taken 9104303 times.
✓ Branch 1 taken 3160 times.
9107463 else if(scored)
5974 {
5975 3160 dir^=1;
5976
5977
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3155 times.
3160 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5978 5 else clk3=32767;
5979 3160 }
5980
5981
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9386997 times.
9463936 if (step != 0) --clk3;
5982 9463936 move(step);
5983 12334139 }
5984
5985 // 8-directional movement, aligns to 8 pixels
5986 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5987 {
5988 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5989 return;
5990
5991 if(clk3<=0)
5992 {
5993 newdir_8(newrate,newhoming,special);
5994 clk3=int32_t(8.0/step);
5995 if (step == 0) clk3 = 32767;
5996 }
5997
5998 if (step != 0) --clk3;
5999 move(step);
6000 }
6001 // 8-directional movement, aligns to 8 pixels
6002 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6003 {
6004
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6005 return;
6006
6007
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6008 {
6009 16235 newdir_8(newrate,newhoming,special);
6010 16235 clk3=int32_t(8.0/step);
6011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6012 16235 }
6013
6014
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6015 242393 move(step);
6016 242393 }
6017
6018 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6019 {
6020 if(clk<0 || dying || stunclk || watch || frozenclock)
6021 return;
6022
6023 if(!canmove(dir,step,special,false))
6024 clk3=0;
6025
6026 if(clk2>0)
6027 {
6028 --clk2;
6029 return;
6030 }
6031
6032 if(clk3<=0)
6033 {
6034 newdir_8(newrate,newhoming,special);
6035 clk3=newclk;
6036
6037 if(clk2<0)
6038 {
6039 clk2=0;
6040 }
6041 else if((zc_oldrand()&15)<newhrate)
6042 {
6043 newdir_8(newrate,newhoming,special);
6044 clk2=haltcnt;
6045 return;
6046 }
6047 }
6048
6049 --clk3;
6050 move(step);
6051 }
6052
6053 // 8-directional movement, no alignment
6054 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6055 {
6056
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6057 246953 return;
6058
6059
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6060 30488 clk3=0;
6061
6062
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6063 {
6064 558018 newdir_8(newrate,newhoming,special);
6065 558018 clk3=newclk;
6066 558018 }
6067
6068 4474092 --clk3;
6069 4474092 move(step);
6070 4721045 }
6071
6072 // same as above but with variable enemy size
6073 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6074 {
6075
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6076 1247 return;
6077
6078
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6079 1334 clk3=0;
6080
6081
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6082 {
6083 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6084 6475 clk3=newclk;
6085 6475 }
6086
6087 93316 --clk3;
6088 93316 move(step);
6089 94563 }
6090
6091 // the variable speed floater movement
6092 // ms is max speed
6093 // ss is step speed
6094 // s is step count
6095 // p is pause count
6096 // g is graduality :)
6097 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6098 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6099 {
6100 4019514 ++clk2;
6101 4019514 byte over_pit = overpit(this);
6102
6103
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6104
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6105 {
6106 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6107 //! if the conditions prevent it, we jump back to case 2.
6108 case 0: // paused
6109
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6110 {
6111 1451 movestatus=1;
6112 1451 clk2=0;
6113 1451 }
6114
6115 56650 break;
6116
6117 case 1: // speeding up
6118
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6119 {
6120
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6121 {
6122
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6123 101600 step+=ss;
6124 1575074 }
6125 else
6126 {
6127 11306 movestatus=2;
6128 11306 clk2=0;
6129 }
6130 1586380 }
6131 else
6132 {
6133 if(step < ms)
6134 {
6135 if(!((clk2-1)%g))
6136 {
6137 step+=ss;
6138 if (step >= ms) step = ms;
6139 }
6140 }
6141 else
6142 {
6143 step = ms;
6144 movestatus=2;
6145 clk2=0;
6146 }
6147 }
6148
6149 1586380 break;
6150
6151 case 2: // normal
6152 2243416 step=ms;
6153
6154
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6155 {
6156
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6157 else step=ms;
6158 2250 movestatus=3;
6159 2250 clk2=0;
6160 2250 }
6161
6162 2243416 break;
6163
6164 case 3: // slowing down
6165
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6166 {
6167
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6168 {
6169 { //don't slow down over pits
6170
6171
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6172 {
6173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6174 {
6175 step=ms;
6176 }
6177 267 }
6178 else //can slow down
6179 {
6180
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6181 7720 step-=ss;
6182 }
6183 }
6184
6185
6186 131387 }
6187 else
6188 {
6189 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6190 //this doesn't help keese, as they have a z of 0.
6191 //they always nee to run this check.
6192 {
6193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6194 {
6195 --clk2; //if over a pit, don't land, and revert clock change
6196 }
6197 else //can land safely
6198 {
6199 1681 movestatus=0;
6200
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6201 1115 step=0;
6202 1681 clk2=0;
6203 }
6204 }
6205
6206 }
6207 133068 }
6208 else
6209 {
6210 if(step > 0)
6211 {
6212 if(over_pit)
6213 {
6214 if(dmisc1)
6215 {
6216 step=ms;
6217 }
6218 }
6219 else //can slow down
6220 {
6221 if(!(clk2%g))
6222 step-=ss;
6223 }
6224 }
6225 else
6226 {
6227 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6228 //this doesn't help keese, as they have a z of 0.
6229 //they always nee to run this check.
6230 if(over_pit)
6231 {
6232 step+=ss; //if over a pit, don't land, and revert clock change
6233 }
6234 else //can land safely
6235 {
6236 movestatus=0;
6237 step=0;
6238 clk2=0;
6239 }
6240 }
6241 }
6242
6243 133068 break;
6244 }
6245
6246
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6247 4019514 }
6248
6249 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6250 {
6251 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6252 }
6253
6254 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6255 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6256 927949 int32_t enemy::lined_up(int32_t range, bool dir8)
6257 {
6258 927949 int32_t lx = Hero.getX();
6259 927949 int32_t ly = Hero.getY();
6260
6261
2/2
✓ Branch 0 taken 38914 times.
✓ Branch 1 taken 889035 times.
927949 if(abs(lx-int32_t(x))<=range)
6262 {
6263
2/2
✓ Branch 0 taken 16351 times.
✓ Branch 1 taken 22563 times.
38914 if(ly<y)
6264 {
6265 16351 return up;
6266 }
6267
6268 22563 return down;
6269 }
6270
6271
2/2
✓ Branch 0 taken 56361 times.
✓ Branch 1 taken 832674 times.
889035 if(abs(ly-int32_t(y))<=range)
6272 {
6273
2/2
✓ Branch 0 taken 30301 times.
✓ Branch 1 taken 26060 times.
56361 if(lx<x)
6274 {
6275 30301 return left;
6276 }
6277
6278 26060 return right;
6279 }
6280
6281
2/2
✓ Branch 0 taken 160084 times.
✓ Branch 1 taken 672590 times.
832674 if(dir8)
6282 {
6283
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6284 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6285 {
6286
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6287 {
6288
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6289 {
6290 56676 return l_up;
6291 }
6292 else
6293 {
6294 49404 return r_up;
6295 }
6296 }
6297 else
6298 {
6299
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6300 {
6301 71072 return l_down;
6302 }
6303 else
6304 {
6305 76696 return r_down;
6306 }
6307 }
6308 }
6309 418742 }
6310
6311 578826 return -1;
6312 927949 }
6313
6314 // returns true if Hero is within 'range' pixels of the enemy
6315 27884 bool enemy::HeroInRange(int32_t range)
6316 {
6317 27884 int32_t lx = Hero.getX();
6318 27884 int32_t ly = Hero.getY();
6319
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6320 }
6321
6322 // place the enemy in line with Hero (red wizzrobes)
6323 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6324 {
6325
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6326
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6327 4899 int32_t pos2=zc_oldrand()%23;
6328 4899 int32_t tried=0;
6329 4899 bool last_resort,placed=false;
6330
6331
6332 4899 do
6333 {
6334
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6335 {
6336 4460 x=(pos2<<4)+16;
6337 4460 y=ly;
6338 4460 }
6339 else
6340 {
6341 3127 x=lx;
6342 3127 y=((pos2-14)<<4)+16;
6343 }
6344
6345 // Don't commit to a last resort if position is out of bounds.
6346
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6347
6348
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1287 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6349 {
6350 // Red Wizzrobes should be able to appear on water, but not other
6351 // solid combos; however, they could appear on solid combos in 2.10,
6352 // and some quests depend on that.
6353
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6354 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6355 4899 placed=true;
6356 8542 }
6357
6358
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7225 if(!placed && tried>=22 && last_resort)
6359 {
6360 placed=true;
6361 }
6362
6363 7225 ++tried;
6364 7225 pos2=(pos2+3)%23;
6365
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
7225 }
6366 7225 while(!placed);
6367
6368
2/2
✓ Branch 0 taken 2729 times.
✓ Branch 1 taken 1808 times.
4537 if(y==ly)
6369 2729 dir=(x<lx)?right:left;
6370 else
6371 1808 dir=(y<ly)?down:up;
6372
6373 4537 clk2=tried;
6374 4537 }
6375
6376 20335203 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6377 {
6378 20335203 int32_t t = o_tile;
6379 20335203 int32_t b = o_tile;
6380
6381 // Darknuts, but also Wizzrobes and Wallmasters
6382
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877881 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20335203 switch(type)
6383 {
6384 case eeWALK:
6385
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372474 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877881 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6386 {
6387 367468 tile=s_tile;
6388 367468 t=s_tile;
6389 367468 b=s_tile;
6390 367468 }
6391
6392 10877881 break;
6393
6394 case eeTRAP:
6395
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6396 {
6397 193566 tile=s_tile;
6398 193566 t=s_tile;
6399 193566 b=s_tile;
6400 193566 }
6401
6402 1039770 break;
6403
6404 case eeSPINTILE:
6405 if(misc>=96 && do_animation)
6406 {
6407 tile=o_tile+frames*ndir;
6408 t=tile;
6409 }
6410
6411 break;
6412 }
6413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335203 times.
20335203 if ( do_animation )
6414 {
6415
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20138161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19871030 times.
20335203 if(ndir!=0) switch(frames)
6416 {
6417 case 2:
6418 267131 tiledir_small(dir,ndir==4);
6419 267131 break;
6420
6421 case 3:
6422 tiledir_three(dir);
6423 break;
6424
6425 case 4:
6426 19871030 tiledir(dir,ndir==4);
6427 19871030 break;
6428 20138161 }
6429
6430
2/2
✓ Branch 0 taken 10877881 times.
✓ Branch 1 taken 9457322 times.
20335203 if(type==eeWALK)
6431
6/6
✓ Branch 0 taken 10816559 times.
✓ Branch 1 taken 61322 times.
✓ Branch 2 taken 8211621 times.
✓ Branch 3 taken 2666260 times.
✓ Branch 4 taken 2650448 times.
✓ Branch 5 taken 15812 times.
10877881 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6432 else
6433 9457322 tile+=f4;
6434 20335203 }
6435 20335203 return b;
6436 }
6437
6438 void enemy::tiledir_three(int32_t ndir)
6439 {
6440 if ( !do_animation ) return;
6441 flip=0;
6442
6443 switch(ndir)
6444 {
6445 case right:
6446 tile+=3;
6447 [[fallthrough]];
6448
6449 case left:
6450 tile+=3;
6451 [[fallthrough]];
6452
6453 case down:
6454 tile+=3;
6455 [[fallthrough]];
6456
6457 case up:
6458 break;
6459 }
6460 }
6461
6462 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6463 {
6464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6465 267131 flip=0;
6466
6467
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6468 {
6469 case 8:
6470 case up:
6471 53829 break;
6472
6473 case 12:
6474 case down:
6475 54679 tile+=2;
6476 54679 break;
6477
6478 case 14:
6479 case left:
6480 67727 tile+=4;
6481 67727 break;
6482
6483 case 10:
6484 case right:
6485 71182 tile+=6;
6486 71182 break;
6487
6488 case 9:
6489 case r_up:
6490
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6491 5706 break;
6492
6493 tile+=10;
6494 break;
6495
6496 case 11:
6497 case r_down:
6498
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6499 5154 tile+=2;
6500 else
6501 tile+=14;
6502
6503 5154 break;
6504
6505 case 13:
6506 case l_down:
6507
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6508 4872 tile+=2;
6509 else
6510 tile+=12;
6511
6512 4872 break;
6513
6514 case 15:
6515 case l_up:
6516
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6517 3982 break;
6518
6519 tile+=8;
6520 break;
6521
6522 default:
6523 //dir=(zc_oldrand()*100)%8;
6524 //tiledir_small(dir);
6525 // flip=zc_oldrand()&3;
6526 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6527 break;
6528 }
6529 267131 }
6530
6531 23203778 void enemy::tiledir(int32_t ndir, bool fourdir)
6532 {
6533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203778 times.
23203778 if ( !do_animation ) return;
6534 23203778 flip=0;
6535
6536
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163442 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 67162 times.
23203778 switch(ndir)
6537 {
6538 case 8:
6539 case up:
6540 4509460 break;
6541
6542 case 12:
6543 case down:
6544 4163442 tile+=4;
6545 4163442 break;
6546
6547 case 14:
6548 case left:
6549 5444983 tile+=8;
6550 5444983 break;
6551
6552 case 10:
6553 case right:
6554 5198041 tile+=12;
6555 5198041 break;
6556
6557 case 9:
6558 case r_up:
6559
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6560 89257 break;
6561 else
6562 744883 tile+=24;
6563
6564 744883 break;
6565
6566 case 11:
6567 case r_down:
6568
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6569 102657 tile+=4;
6570 else
6571 924955 tile+=32;
6572
6573 1027612 break;
6574
6575 case 13:
6576 case l_down:
6577
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6578 106171 tile+=4;
6579 else
6580 1000286 tile+=28;
6581
6582 1106457 break;
6583
6584 case 15:
6585 case l_up:
6586
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6587 82882 break;
6588 else
6589 769599 tile+=20;
6590
6591 769599 break;
6592
6593 default:
6594 //dir=(zc_oldrand()*100)%8;
6595 //tiledir(dir);
6596 // flip=zc_oldrand()&3;
6597 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6598 67162 break;
6599 }
6600 23203778 }
6601
6602 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6603 {
6604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6605 3868 flip=0;
6606
6607
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6608 {
6609 case 8:
6610 case up:
6611 297 break;
6612
6613 case 12:
6614 case down:
6615 tile+=8;
6616 break;
6617
6618 case 14:
6619 case left:
6620 195 tile+=40;
6621 195 break;
6622
6623 case 10:
6624 case right:
6625 179 tile+=48;
6626 179 break;
6627
6628 case 9:
6629 case r_up:
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6631 break;
6632
6633 306 tile+=88;
6634 306 break;
6635
6636 case 11:
6637 case r_down:
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6639 tile+=8;
6640 else
6641 1235 tile+=128;
6642
6643 1235 break;
6644
6645 case 13:
6646 case l_down:
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6648 tile+=8;
6649 else
6650 1324 tile+=120;
6651
6652 1324 break;
6653
6654 case 15:
6655 case l_up:
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6657 break;
6658
6659 332 tile+=80;
6660 332 break;
6661
6662 default:
6663 //dir=(zc_oldrand()*100)%8;
6664 //tiledir_big(dir);
6665 // flip=zc_oldrand()&3;
6666 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6667 break;
6668 }
6669 3868 }
6670
6671 40162690 void enemy::update_enemy_frame()
6672 {
6673
4/4
✓ Branch 0 taken 40160315 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40160308 times.
40162690 if(fallclk||drownclk) return;
6674
1/2
✓ Branch 0 taken 40160308 times.
✗ Branch 1 not taken.
40160308 if (!do_animation)
6675 return;
6676
6677
4/4
✓ Branch 0 taken 1549487 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 1547480 times.
✓ Branch 3 taken 2007 times.
40160308 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6678
6679
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40160308 if(get_qr(qr_ANONE_NOANIM)
6680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40160308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40160308 && anim == aNONE && type != eeGUY)
6681 return;
6682
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39788932 times.
40160308 int32_t newfrate = zc_max(frate,4);
6683 40160308 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6684 40160308 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6685
2/2
✓ Branch 0 taken 30164014 times.
✓ Branch 1 taken 9996294 times.
40160308 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6686 40160308 tile = o_tile;
6687 40160308 int32_t basetile = o_tile;
6688 40160308 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6689 40160308 bool ignore_extend = false;
6690
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134724 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40160308 switch(anim)
6691 {
6692
6693 case aDONGO:
6694 {
6695 69324 int32_t fr = stunclk>0 ? 16 : 8;
6696
6697
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6698 {
6699 // bloated
6700
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6701 {
6702 case up:
6703 960 tile+=9;
6704 960 flip=0;
6705 960 xofs=0;
6706 960 dummy_int[1]=0; //no additional tiles
6707 960 break;
6708
6709 case down:
6710 960 tile+=7;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case left:
6717 1664 flip=1;
6718 1664 tile+=4;
6719 1664 xofs=16;
6720 1664 dummy_int[1]=1; //second tile is next tile
6721 1664 break;
6722
6723 case right:
6724 896 flip=0;
6725 896 tile+=5;
6726 896 xofs=16;
6727 896 dummy_int[1]=-1; //second tile is previous tile
6728 896 break;
6729 }
6730 4480 }
6731
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6732 {
6733 // normal
6734
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6735 {
6736 case up:
6737 13652 tile+=8;
6738 13652 flip=(clk&fr)?1:0;
6739 13652 xofs=0;
6740 13652 dummy_int[1]=0; //no additional tiles
6741 13652 break;
6742
6743 case down:
6744 15374 tile+=6;
6745 15374 flip=(clk&fr)?1:0;
6746 15374 xofs=0;
6747 15374 dummy_int[1]=0; //no additional tiles
6748 15374 break;
6749
6750 case left:
6751 19615 flip=1;
6752 19615 tile+=(clk&fr)?2:0;
6753 19615 xofs=16;
6754 19615 dummy_int[1]=1; //second tile is next tile
6755 19615 break;
6756
6757 case right:
6758 15086 flip=0;
6759 15086 tile+=(clk&fr)?3:1;
6760 15086 xofs=16;
6761 15086 dummy_int[1]=-1; //second tile is next tile
6762 15086 break;
6763 }
6764 63727 }
6765 }
6766 69324 break;
6767
6768 case aNEWDONGO:
6769 {
6770 53456 int32_t fr4=0;
6771
6772
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6773 {
6774 // bloated
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6776 {
6777 2752 fr4=3;
6778 2752 }
6779
6780
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6781 {
6782 2107 fr4=2;
6783 2107 }
6784
6785
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6786 {
6787 1419 fr4=1;
6788 1419 }
6789
6790
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6791 {
6792 731 fr4=0;
6793 731 }
6794
6795
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6796 {
6797 case up:
6798 256 xofs=0;
6799 256 tile+=8+fr4;
6800 256 dummy_int[1]=0; //no additional tiles
6801 256 break;
6802
6803 case down:
6804 576 xofs=0;
6805 576 tile+=12+fr4;
6806 576 dummy_int[1]=0; //no additional tiles
6807 576 break;
6808
6809 case left:
6810 704 tile+=29+(2*fr4);
6811 704 xofs=16;
6812 704 dummy_int[1]=-1; //second tile is previous tile
6813 704 break;
6814
6815 case right:
6816 1216 tile+=49+(2*fr4);
6817 1216 xofs=16;
6818 1216 dummy_int[1]=-1; //second tile is previous tile
6819 1216 break;
6820 }
6821 2752 }
6822
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6823 {
6824 // normal
6825
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6826 {
6827 case up:
6828 9234 xofs=0;
6829 9234 tile+=((clk&12)>>2);
6830 9234 dummy_int[1]=0; //no additional tiles
6831 9234 break;
6832
6833 case down:
6834 9871 xofs=0;
6835 9871 tile+=4+((clk&12)>>2);
6836 9871 dummy_int[1]=0; //no additional tiles
6837 9871 break;
6838
6839 case left:
6840 15025 tile+=21+((clk&12)>>1);
6841 15025 xofs=16;
6842 15025 dummy_int[1]=-1; //second tile is previous tile
6843 15025 break;
6844
6845 case right:
6846 15676 flip=0;
6847 15676 tile+=41+((clk&12)>>1);
6848 15676 xofs=16;
6849 15676 dummy_int[1]=-1; //second tile is previous tile
6850 15676 break;
6851 }
6852 49806 }
6853 }
6854 53456 break;
6855
6856 case aDONGOBS:
6857 {
6858 38833 int32_t fr4=0;
6859
6860
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6861 {
6862 // bloated
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6864 {
6865 2688 fr4=3;
6866 2688 }
6867
6868
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6869 {
6870 2058 fr4=2;
6871 2058 }
6872
6873
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6874 {
6875 1386 fr4=1;
6876 1386 }
6877
6878
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6879 {
6880 714 fr4=0;
6881 714 }
6882
6883
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6884 {
6885 case up:
6886 256 tile+=28+fr4;
6887 256 yofs+=8;
6888 256 dummy_int[1]=-20; //second tile change
6889 256 dummy_int[2]=0; //new xofs change
6890 256 dummy_int[3]=-16; //new xofs change
6891 256 break;
6892
6893 case down:
6894 384 tile+=12+fr4;
6895 384 yofs-=8;
6896 384 dummy_int[1]=20; //second tile change
6897 384 dummy_int[2]=0; //new xofs change
6898 384 dummy_int[3]=16; //new xofs change
6899 384 break;
6900
6901 case left:
6902 1024 tile+=49+(2*fr4);
6903 1024 xofs+=8;
6904 1024 dummy_int[1]=-1; //second tile change
6905 1024 dummy_int[2]=-16; //new xofs change
6906 1024 dummy_int[3]=0; //new xofs change
6907 1024 break;
6908
6909 case right:
6910 1024 tile+=69+(2*fr4);
6911 1024 xofs+=8;
6912 1024 dummy_int[1]=-1; //second tile change
6913 1024 dummy_int[2]=-16; //new xofs change
6914 1024 dummy_int[3]=0; //new xofs change
6915 1024 break;
6916 }
6917 2688 }
6918
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6919 {
6920 // normal
6921
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6922 {
6923 case up:
6924 7136 tile+=20+((clk&24)>>3);
6925 7136 yofs+=8;
6926 7136 dummy_int[1]=-20; //second tile change
6927 7136 dummy_int[2]=0; //new xofs change
6928 7136 dummy_int[3]=-16; //new xofs change
6929 7136 break;
6930
6931 case down:
6932 6672 tile+=4+((clk&24)>>3);
6933 6672 yofs-=8;
6934 6672 dummy_int[1]=20; //second tile change
6935 6672 dummy_int[2]=0; //new xofs change
6936 6672 dummy_int[3]=16; //new xofs change
6937 6672 break;
6938
6939 case left:
6940 11075 xofs=-8;
6941 11075 tile+=40+((clk&24)>>2);
6942 11075 dummy_int[1]=1; //second tile change
6943 11075 dummy_int[2]=16; //new xofs change
6944 11075 dummy_int[3]=0; //new xofs change
6945 11075 break;
6946
6947 case right:
6948 10601 tile+=60+((clk&24)>>2);
6949 10601 xofs=-8;
6950 10601 dummy_int[1]=1; //second tile change
6951 10601 dummy_int[2]=16; //new xofs change
6952 10601 dummy_int[3]=0; //new xofs change
6953 10601 break;
6954 }
6955 35484 }
6956 }
6957 38833 break;
6958
6959 case aWIZZ:
6960 {
6961 // if(d->misc1)
6962
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6963 {
6964
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6965 {
6966 91127 ++tile;
6967 91127 }
6968 182184 }
6969 else
6970 {
6971
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6972 {
6973 136489 ++tile;
6974 136489 }
6975 }
6976
6977
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6978 {
6979 case 9:
6980 case 15:
6981 case up:
6982 76094 tile+=2;
6983 76094 break;
6984
6985 case down:
6986 76591 break;
6987
6988 case 13:
6989 case left:
6990 157108 flip=1;
6991 157108 break;
6992
6993 default:
6994 145581 flip=0;
6995 145581 break;
6996 }
6997 }
6998 455374 break;
6999
7000 case aNEWWIZZ:
7001 {
7002 1525813 tiledir(dir,true);
7003
7004 // if(d->misc1) //walking wizzrobe
7005
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7006 {
7007
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7008 {
7009 369103 tile+=2;
7010 369103 }
7011
7012
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7013 {
7014 370339 tile+=1;
7015 370339 }
7016
7017
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7018 {
7019
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7020 {
7021 79162 tile+=40;
7022 79162 }
7023 742424 }
7024 742424 }
7025 else
7026 {
7027
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7028 {
7029 235972 tile+=20;
7030
7031
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7032 {
7033 168836 tile+=20;
7034 168836 }
7035 235972 }
7036
7037 783389 tile+=((frame>>1)&3);
7038 }
7039 }
7040 1525813 break;
7041
7042 case a3FRM:
7043 {
7044
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7045 }
7046 197042 break;
7047
7048 case a3FRM4DIR:
7049 {
7050 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7051 }
7052 break;
7053
7054 case aVIRE:
7055 {
7056
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7057 {
7058 29292 tile+=2;
7059 29292 }
7060
7061 128880 tile+=fx;
7062 }
7063 128880 break;
7064
7065 case aROPE:
7066 {
7067 220021 tile+=(1-fx);
7068 220021 flip = dir==left ? 1:0;
7069 }
7070 220021 break;
7071
7072 case aZORA:
7073 {
7074 int32_t dl;
7075
7076
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7077 {
7078 46739 dl=clk+5;
7079 46739 goto waves2;
7080 }
7081
7082
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7083
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7084 else
7085 {
7086 92458 dl=clk-36-66;
7087 waves2:
7088 139197 tile=((dl/11)&1)+s_tile;
7089 139197 basetile = s_tile;
7090 }
7091 }
7092 221637 break;
7093
7094 case aNEWZORA:
7095 {
7096 693272 f4=(clk/16)%4;
7097
7098 693272 tiledir(dir,true);
7099 int32_t dl;
7100
7101
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7102 {
7103
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7104 {
7105 174585 tile+=80;
7106 174585 } //mouth closed
7107 else
7108 {
7109 64091 tile+=40;
7110 }
7111
7112 238676 tile+=f4;
7113 238676 }
7114 else
7115 {
7116
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7117 {
7118 203292 dl=clk+5;
7119 203292 }
7120 else
7121 {
7122 251304 dl=clk-36-66;
7123 }
7124
7125 454596 tile+=((dl/5)&3);
7126 }
7127 }
7128 693272 break;
7129
7130 case a4FRM4EYE:
7131 case a2FRM4EYE:
7132 case a4FRM8EYE:
7133 case a4FRM8EYEB: //big version
7134 case a4FRM4EYEB:
7135 {
7136 836734 tilerows = 2;
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7139 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7140 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7141 836734 int32_t lookat=zc_oldrand()&15;
7142
7143
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7144 {
7145 210774 lookat=l_down;
7146 210774 }
7147
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7148 {
7149 226850 lookat=down;
7150 226850 }
7151
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7152 {
7153 108837 lookat=r_down;
7154 108837 }
7155
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7156 {
7157 70395 lookat=right;
7158 70395 }
7159
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7160 {
7161 35067 lookat=r_up;
7162 35067 }
7163
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7164 {
7165 25436 lookat=up;
7166 25436 }
7167
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7168 {
7169 36803 lookat=l_up;
7170 36803 }
7171 else
7172 {
7173 122572 lookat=left;
7174 }
7175
7176 836734 int32_t dir2 = dir;
7177 836734 dir = lookat;
7178
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7179 else
7180 {
7181 tiledir_big(dir,(anim == a4FRM4EYEB));
7182 tile+=2*f4;
7183 ignore_extend = true;
7184 }
7185 836734 dir = dir2;
7186 }
7187 836734 break;
7188
7189 case aFLIP:
7190 {
7191 1694695 flip = f2&1;
7192 }
7193 1694695 break;
7194
7195 case a2FRM:
7196 {
7197 1134909 tile += (1-f2);
7198 }
7199 1134909 break;
7200
7201 case a2FRMB:
7202 {
7203 tile+= 2*(1-f2);
7204 ignore_extend = true;
7205 }
7206 break;
7207
7208 case a2FRM4DIR:
7209 {
7210 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7211 }
7212 267131 break;
7213
7214 case a4FRM4DIRF:
7215 {
7216 4134724 basetile = n_frame_n_dir(4,4,f4);
7217
7218
2/2
✓ Branch 0 taken 2733716 times.
✓ Branch 1 taken 1401008 times.
4134724 if(clk2>0) //stopped to fire
7219 {
7220 1401008 tile+=20;
7221
7222
2/2
✓ Branch 0 taken 698282 times.
✓ Branch 1 taken 702726 times.
1401008 if(clk2<17) //firing
7223 {
7224 702726 tile+=20;
7225 702726 }
7226 1401008 }
7227 }
7228 4134724 break;
7229
7230 case a4FRM4DIR:
7231 {
7232 7515986 basetile = n_frame_n_dir(4,4,f4);
7233 }
7234 7515986 break;
7235
7236 case a4FRM8DIRF:
7237 {
7238 tilerows = 2;
7239 basetile = n_frame_n_dir(4,8,f4);
7240
7241 if(clk2>0) //stopped to fire
7242 {
7243 tile+=40;
7244
7245 if(clk2<17) //firing
7246 {
7247 tile+=40;
7248 }
7249 }
7250 }
7251 break;
7252
7253 case a4FRM8DIRB:
7254 case a4FRM8DIRFB:
7255 {
7256 3868 tilerows = 2;
7257 3868 tiledir_big(dir,false);
7258 3868 tile+=2*f4;
7259
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7260 {
7261 tile+=80;
7262
7263 if(clk2<17) //firing
7264 {
7265 tile+=80;
7266 }
7267 }
7268 3868 ignore_extend = true;
7269 }
7270 3868 break;
7271
7272 case a4FRM4DIRB:
7273 case a4FRM4DIRFB:
7274 {
7275 tilerows = 2;
7276 tiledir_big(dir,true);
7277 tile+=2*f4;
7278 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7279 {
7280 tile+=40;
7281
7282 if(clk2<17) //firing
7283 {
7284 tile+=40;
7285 }
7286 }
7287 ignore_extend = true;
7288 }
7289 break;
7290
7291 case aOCTO:
7292 {
7293
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7294 {
7295 case up:
7296 122459 flip = 2;
7297 122459 break;
7298
7299 case down:
7300 133448 flip = 0;
7301 133448 break;
7302
7303 case left:
7304 165651 flip = 0;
7305 165651 tile += 2;
7306 165651 break;
7307
7308 case right:
7309 157227 flip = 1;
7310 157227 tile += 2;
7311 157227 break;
7312 }
7313
7314 582937 tile+=f2;
7315 }
7316 582937 break;
7317
7318 case aWALK:
7319 {
7320
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7321 {
7322 case up:
7323 248704 tile+=3;
7324 248704 flip = f2;
7325 248704 break;
7326
7327 case down:
7328 267165 tile+=2;
7329 267165 flip = f2;
7330 267165 break;
7331
7332 case left:
7333 331694 flip=1;
7334 331694 tile += f2;
7335 331694 break;
7336
7337 case right:
7338 325802 flip=0;
7339 325802 tile += f2;
7340 325802 break;
7341 }
7342 }
7343 1178979 break;
7344
7345 case aDWALK:
7346 {
7347
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7348 {
7349 tile=s_tile;
7350 basetile = s_tile;
7351 }
7352
7353
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7354 {
7355 case up:
7356 177728 tile+=2;
7357 177728 flip=f2;
7358 177728 break;
7359
7360 case down:
7361 185581 flip=0;
7362 185581 tile+=(1-f2);
7363 185581 break;
7364
7365 case left:
7366 260885 flip=1;
7367 260885 tile+=(3+f2);
7368 260885 break;
7369
7370 case right:
7371 255982 flip=0;
7372 255982 tile+=(3+f2);
7373 255982 break;
7374 }
7375 }
7376 880176 break;
7377
7378 case aTEK:
7379 {
7380
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7381 {
7382 79120 tile += f2;
7383 79120 }
7384
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7385 {
7386 66827 ++tile;
7387 66827 }
7388 }
7389 219096 break;
7390
7391 case aNEWTEK:
7392 {
7393
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7394 {
7395
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7396 {
7397 case left:
7398 235369 flip=0;
7399 235369 tile+=20;
7400 235369 break;
7401
7402 case right:
7403 239877 flip=0;
7404 239877 tile+=24;
7405 239877 break;
7406 }
7407 475246 }
7408
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7409 {
7410
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7411 {
7412 case left:
7413 40566 flip=0;
7414 40566 tile+=8;
7415 40566 break;
7416
7417 case right:
7418 14183 flip=0;
7419 14183 tile+=12;
7420 14183 break;
7421 }
7422 54749 } //down
7423 else
7424 {
7425
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7426 {
7427 case left:
7428 593340 flip=0;
7429 593340 tile+=28;
7430 593340 break;
7431
7432 case right:
7433 585820 flip=0;
7434 585820 tile+=32;
7435 585820 break;
7436 }
7437 }
7438
7439
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7440 {
7441 579549 tile+=f4;
7442 579549 }
7443
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7444 {
7445 656670 tile+=2;
7446 656670 }
7447 }
7448 1818304 break;
7449
7450 case aARMOS:
7451 {
7452
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7453 {
7454 5401 tile += fx;
7455
7456
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7457 1197 tile += 2;
7458 5401 }
7459 }
7460 8628 break;
7461
7462 case aARMOS4:
7463 {
7464
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7465 {
7466 case up:
7467 29165 flip=0;
7468 29165 break;
7469
7470 case down:
7471 92624 flip=0;
7472 92624 tile+=4;
7473 92624 break;
7474
7475 case left:
7476 43654 flip=0;
7477 43654 tile+=8;
7478 43654 break;
7479
7480 case right:
7481 43190 flip=0;
7482 43190 tile+=12;
7483 43190 break;
7484 }
7485
7486
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7487 {
7488 145928 tile+=f4;
7489 145928 }
7490 }
7491 209083 break;
7492
7493 case aGHINI:
7494 {
7495
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7496 {
7497 case 8:
7498 case 9:
7499 case up:
7500 28037 ++tile;
7501 28037 flip=0;
7502 28037 break;
7503
7504 case 15:
7505 452 ++tile;
7506 452 flip=1;
7507 452 break;
7508
7509 case 10:
7510 case 11:
7511 case right:
7512 32092 flip=1;
7513 32092 break;
7514
7515 default:
7516 72763 flip=0;
7517 72763 break;
7518 }
7519 }
7520 133344 break;
7521
7522 case a2FRMPOS:
7523 {
7524 1755010 tile+=posframe;
7525 }
7526 1755010 break;
7527
7528 case a4FRMPOS4DIR:
7529 {
7530 363745 basetile = n_frame_n_dir(4,4,0);
7531 // tile+=f2;
7532 363745 tile+=posframe;
7533 }
7534 363745 break;
7535
7536 case a4FRMPOS4DIRF:
7537 {
7538 1433 basetile = n_frame_n_dir(4,4,0);
7539
7540
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7541 {
7542 197 tile+=20;
7543
7544
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7545 {
7546 64 tile+=20;
7547 64 }
7548 197 }
7549
7550 // tile+=f2;
7551 1433 tile+=posframe;
7552 }
7553 1433 break;
7554
7555 case a4FRMPOS8DIR:
7556 {
7557 7018408 tilerows = 2;
7558 7018408 int32_t n = tile;
7559 7018408 basetile = n_frame_n_dir(4,8,0);
7560 // tile+=f2;
7561 7018408 tile+=posframe;
7562 }
7563 7018408 break;
7564
7565 case a4FRMPOS8DIRF:
7566 {
7567 tilerows = 2;
7568 basetile = n_frame_n_dir(4,8,0);
7569
7570 if(clk2>0) //stopped to fire
7571 {
7572 tile+=40;
7573
7574 if(clk2<17) //firing
7575 {
7576 tile+=40;
7577 }
7578 }
7579
7580 tile+=posframe;
7581 }
7582 break;
7583
7584 case aNEWLEV:
7585 {
7586 747030 tiledir(dir,true);
7587
7588
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7589 {
7590 case -1:
7591 case 0:
7592 258994 return;
7593
7594 case 1:
7595
7596 // case 5: cs = d->misc2; break;
7597 case 5:
7598 115368 cs = dmisc2;
7599 115368 break;
7600
7601 case 2:
7602 case 4:
7603 48980 tile += 20;
7604 48980 break;
7605
7606 case 3:
7607 323688 tile += 40;
7608 323688 break;
7609 }
7610
7611 488036 tile+=f4;
7612 }
7613 488036 break;
7614
7615 case aLEV:
7616 {
7617 276997 f4 = ((clk/5)&1);
7618
7619
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7620 {
7621 case -1:
7622 case 0:
7623 127945 return;
7624
7625 case 1:
7626
7627 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7628 case 5:
7629 33336 tile += (f2) ? 1 : 0;
7630 33336 cs = dmisc2;
7631 33336 break;
7632
7633 case 2:
7634 case 4:
7635 14658 tile += 2;
7636 14658 break;
7637
7638 case 3:
7639 101058 tile += (f4) ? 4 : 3;
7640 101058 break;
7641 }
7642 }
7643 149052 break;
7644
7645 case aWALLM:
7646 {
7647
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7648 {
7649 139764 tile += f2;
7650 139764 }
7651 }
7652 140514 break;
7653
7654 case aNEWWALLM:
7655 {
7656 366633 int32_t tempdir=0;
7657
7658
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7659 {
7660 case 1:
7661 case 2:
7662 43340 tempdir=clk3;
7663 43340 break;
7664
7665 case 3:
7666 case 4:
7667 case 5:
7668 38855 tempdir=dir;
7669 38855 break;
7670
7671 case 6:
7672 case 7:
7673 8438 tempdir=clk3^1;
7674 8438 break;
7675 }
7676
7677 366633 tiledir(tempdir,true);
7678
7679
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7680 {
7681 364725 tile+=f4;
7682 364725 }
7683 }
7684 366633 break;
7685
7686 case a4FRMNODIR:
7687 {
7688 171508 tile+=f4;
7689 }
7690 171508 break;
7691
7692 } // switch(d->anim)
7693
7694 // flashing
7695 // if(d->flags & guy_flashing)
7696
2/2
✓ Branch 0 taken 39025820 times.
✓ Branch 1 taken 747549 times.
39773369 if(flags & guy_flashing)
7697 {
7698 747549 cs = (frame&3) + 6;
7699 747549 }
7700
7701
2/2
✓ Branch 0 taken 39362421 times.
✓ Branch 1 taken 410948 times.
39773369 if(flags&guy_transparent)
7702 {
7703 410948 drawstyle=1;
7704 410948 }
7705
7706 39773369 int32_t change = tile-basetile;
7707
7708
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37718426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39773369 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7709 {
7710
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7711 {
7712 1792915 tile=basetile+txsz*change;
7713 1792915 }
7714 else
7715 {
7716 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7717 }
7718 2054943 }
7719 else
7720 {
7721 37718426 tile=basetile+change;
7722 }
7723 40162690 }
7724
7725 81117 int32_t enemy::wpnsfx(int32_t wpn)
7726 {
7727
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40991 times.
✓ Branch 2 taken 17707 times.
81117 switch (wpn)
7728 {
7729 case wScript1:
7730 case wScript2:
7731 case wScript3:
7732 case wScript4:
7733 case wScript5:
7734 case wScript6:
7735 case wScript7:
7736 case wScript8:
7737 case wScript9:
7738 case wScript10: //sure why not
7739 case ewFireTrail:
7740 case ewFlame:
7741 case ewFlame2Trail:
7742 case ewFlame2:
7743 case ewWind:
7744 case ewMagic:
7745 case ewIce:
7746 22419 return firesfx;
7747
7748 case ewRock:
7749 case ewFireball2:
7750 case ewFireball:
7751
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 35458 times.
40991 if (get_qr(qr_MORESOUNDS)) return firesfx;
7752 35458 break;
7753 }
7754
7755 53165 return 0;
7756 81117 }
7757
7758 77044177 int32_t enemy::run_script(int32_t mode)
7759 {
7760 void push_ri();
7761 void pop_ri();
7762
7763
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77044177 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7764
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77043921 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7765 77043921 return RUNSCRIPT_OK;
7766 auto scrty = *get_scrtype();
7767 auto uid = getUID();
7768 if(!FFCore.doscript(scrty,uid))
7769 return RUNSCRIPT_OK;
7770 int32_t ret = RUNSCRIPT_OK;
7771 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7772 push_ri();
7773 switch(mode)
7774 {
7775 case MODE_NORMAL:
7776 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7777 break;
7778
7779 case MODE_WAITDRAW:
7780 if(waitdraw)
7781 {
7782 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7783 waitdraw = false;
7784 }
7785 break;
7786 }
7787 pop_ri();
7788 return ret;
7789 77044177 }
7790 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7791 {
7792 return al_map_rgba(255,0,0,opacity);
7793 }
7794
7795 // good guys, fires, fairy, and other non-enemies
7796 // based on enemy class b/c guys in dungeons act sort of like enemies
7797 // also easier to manage all the guys this way
7798 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7799 2191 {
7800 2191 mainguy=mg;
7801 2191 canfreeze=false;
7802 2191 dir=down;
7803
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7804 2191 hxofs=2;
7805 2191 hzsz=8;
7806 2191 hit_width=12;
7807 2191 hit_height=17;
7808
7809
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7810 {
7811 1931 superman = 1;
7812 1931 hxofs=1000;
7813 1931 }
7814 2191 }
7815
7816 943762 bool guy::animate(int32_t index)
7817 {
7818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7819
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7820 {
7821 1206 setupscreen();
7822 1206 misc = 1;
7823 1206 }
7824
7825
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7826 330 return true;
7827
7828 943432 hp=256; // good guys never die...
7829
7830
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7831 {
7832 // but if they get hit...
7833 16 ++clk2; // only do this once
7834
7835
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7836 {
7837 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7838 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7839 7 }
7840 16 }
7841
7842 943432 return enemy::animate(index);
7843 943762 }
7844
7845 947535 void guy::draw(BITMAP *dest)
7846 {
7847 947535 update_enemy_frame();
7848
7849
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7850 935688 enemy::draw(dest);
7851 947535 }
7852
7853 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7854 760 {
7855 760 clk4=0;
7856
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7857 // Spawn type
7858
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7859 {
7860 clk=0;
7861 superman = 1;
7862 fading=fade_flicker;
7863 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7864 dir=down;
7865
7866 if(!canmove(down,(zfix)8,spw_none,false))
7867 clk3=int32_t(13.0/step);
7868 }
7869
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7870 {
7871 84 clk=0;
7872 84 }
7873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7874 760 }
7875
7876 167472 bool eFire::animate(int32_t index)
7877 {
7878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7879
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7880
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7881 {
7882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7883 {
7884 1 clk4=0;
7885 1 superman=0;
7886 1 fading=0;
7887
7888
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7889 removearmos(x,y,ffcactivated);
7890
7891 1 clk2=0;
7892
7893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7894 {
7895 1 dir=0;
7896 1 y = TRUNCATE_TILE(y.getInt());
7897 1 }
7898
7899 1 return Dead(index);
7900 }
7901
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7902 removearmos(x,y,ffcactivated);
7903 1715 }
7904
7905 167471 return enemy::animate(index);
7906 167472 }
7907
7908 351659 void eFire::draw(BITMAP *dest)
7909 {
7910 351659 update_enemy_frame();
7911 351659 enemy::draw(dest);
7912 351659 }
7913
7914 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7915 {
7916 415 int32_t wpnId = w->id;
7917 415 int32_t wpnDir = w->dir;
7918
7919
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7920 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7921 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7922 {
7923 shield = false;
7924 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7925
7926 if(get_qr(qr_BRKNSHLDTILES))
7927 o_tile=s_tile;
7928 }
7929
7930 415 int32_t ret = enemy::takehit(w,realweap);
7931 415 return ret;
7932 }
7933
7934 void eFire::break_shield()
7935 {
7936 if(!shield)
7937 return;
7938
7939 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7940 shield=false;
7941
7942 if(get_qr(qr_BRKNSHLDTILES))
7943 o_tile=s_tile;
7944 }
7945
7946 void eFire::repair_shield()
7947 {
7948 if (shield)
7949 return;
7950
7951 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7952 return;
7953
7954 shield = true;
7955
7956 if (get_qr(qr_BRKNSHLDTILES))
7957 {
7958 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7959 else o_tile = d->tile;
7960 }
7961 }
7962
7963 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7964 7630 {
7965 7630 clk4=0;
7966
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7967
7968 // Spawn type
7969
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7970 {
7971 clk=0;
7972 superman = 1;
7973 fading=fade_flicker;
7974 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7975 dir=down;
7976
7977 if(!canmove(down,(zfix)8,spw_none,false))
7978 clk3=int32_t(13.0/step);
7979 }
7980
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7981 {
7982 1187 clk=0;
7983 1187 }
7984
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7985 7630 }
7986
7987 1981512 bool eOther::animate(int32_t index)
7988 {
7989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7990
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7991
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7992 {
7993
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7994 {
7995 29 clk4=0;
7996 29 superman=0;
7997 29 fading=0;
7998
7999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8000 removearmos(x,y,ffcactivated);
8001
8002 29 clk2=0;
8003
8004
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8005 {
8006 2 dir=0;
8007 2 y = TRUNCATE_TILE(y.getInt());
8008 2 }
8009
8010 29 return Dead(index);
8011 }
8012
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8013 removearmos(x,y,ffcactivated);
8014 8507 }
8015
8016 1979897 return enemy::animate(index);
8017 1981512 }
8018
8019 2087673 void eOther::draw(BITMAP *dest)
8020 {
8021 2087673 update_enemy_frame();
8022 2087673 enemy::draw(dest);
8023 2087673 }
8024
8025 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8026 {
8027 14773 int32_t wpnId = w->id;
8028 14773 int32_t wpnDir = w->dir;
8029
8030
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8031 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8032 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8033 {
8034 shield = false;
8035 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8036
8037 if(get_qr(qr_BRKNSHLDTILES))
8038 o_tile=s_tile;
8039 }
8040
8041 14773 int32_t ret = enemy::takehit(w,realweap);
8042 14773 return ret;
8043 }
8044
8045 void eOther::break_shield()
8046 {
8047 if(!shield)
8048 return;
8049
8050 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8051 shield=false;
8052
8053 if(get_qr(qr_BRKNSHLDTILES))
8054 o_tile=s_tile;
8055 }
8056
8057 void eOther::repair_shield()
8058 {
8059 if (shield)
8060 return;
8061
8062 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8063 return;
8064
8065 shield = true;
8066
8067 if (get_qr(qr_BRKNSHLDTILES))
8068 {
8069 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8070 else o_tile = d->tile;
8071 }
8072 }
8073
8074 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8075 {
8076 clk4=0;
8077 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8078
8079 // Spawn type
8080 if(flags & guy_fade_flicker)
8081 {
8082 clk=0;
8083 superman = 1;
8084 fading=fade_flicker;
8085 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8086 dir=down;
8087
8088 if(!canmove(down,(zfix)8,spw_none,false))
8089 clk3=int32_t(13.0/step);
8090 }
8091 else if(flags & guy_fade_instant)
8092 {
8093 clk=0;
8094 }
8095 if (SIZEflags != 0) init_size_flags();;
8096 }
8097
8098 bool eScript::animate(int32_t index)
8099 {
8100 if(switch_hooked) return enemy::animate(index);
8101 if(fallclk||drownclk) return enemy::animate(index);
8102 if(fading)
8103 {
8104 if(++clk4 > 60)
8105 {
8106 clk4=0;
8107 superman=0;
8108 fading=0;
8109
8110 if(flags&guy_armos && z==0 && fakez==0)
8111 removearmos(x,y,ffcactivated);
8112
8113 clk2=0;
8114
8115 if(!canmove(down,(zfix)8,spw_none,false))
8116 {
8117 dir=0;
8118 y = TRUNCATE_TILE(y.getInt());
8119 }
8120
8121 return Dead(index);
8122 }
8123 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8124 removearmos(x,y,ffcactivated);
8125 }
8126
8127 return enemy::animate(index);
8128 }
8129
8130 void eScript::draw(BITMAP *dest)
8131 {
8132 update_enemy_frame();
8133 enemy::draw(dest);
8134 }
8135
8136 int32_t eScript::takehit(weapon *w, weapon* realweap)
8137 {
8138 int32_t wpnId = w->id;
8139 int32_t wpnDir = w->dir;
8140
8141 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8142 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8143 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8144 {
8145 shield = false;
8146 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8147
8148 if(get_qr(qr_BRKNSHLDTILES))
8149 o_tile=s_tile;
8150 }
8151
8152 int32_t ret = enemy::takehit(w,realweap);
8153 return ret;
8154 }
8155
8156 void eScript::break_shield()
8157 {
8158 if(!shield)
8159 return;
8160
8161 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8162 shield=false;
8163
8164 if(get_qr(qr_BRKNSHLDTILES))
8165 o_tile=s_tile;
8166 }
8167
8168 void eScript::repair_shield()
8169 {
8170 if (shield)
8171 return;
8172
8173 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8174 return;
8175
8176 shield = true;
8177
8178 if (get_qr(qr_BRKNSHLDTILES))
8179 {
8180 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8181 else o_tile = d->tile;
8182 }
8183 }
8184
8185
8186 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8187 {
8188 clk4=0;
8189 hyofs = -32768; //No hitbox initially.
8190 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8191
8192 // Spawn type
8193 if(flags & guy_fade_flicker)
8194 {
8195 clk=0;
8196 superman = 1;
8197 fading=fade_flicker;
8198 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8199 dir=down;
8200
8201 if(!canmove(down,(zfix)8,spw_none,false))
8202 clk3=int32_t(13.0/step);
8203 }
8204 else if(flags & guy_fade_instant)
8205 {
8206 clk=0;
8207 }
8208 if (SIZEflags != 0) init_size_flags();;
8209 }
8210
8211 bool eFriendly::animate(int32_t index)
8212 {
8213 if(switch_hooked) return enemy::animate(index);
8214 if(fallclk||drownclk) return enemy::animate(index);
8215 if(fading)
8216 {
8217 if(++clk4 > 60)
8218 {
8219 clk4=0;
8220 superman=0;
8221 fading=0;
8222
8223 if(flags&guy_armos && z==0 && fakez==0)
8224 removearmos(x,y,ffcactivated);
8225
8226 clk2=0;
8227
8228 if(!canmove(down,(zfix)8,spw_none,false))
8229 {
8230 dir=0;
8231 y = TRUNCATE_TILE(y.getInt());
8232 }
8233
8234 return Dead(index);
8235 }
8236 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8237 removearmos(x,y,ffcactivated);
8238 }
8239
8240 return enemy::animate(index);
8241 }
8242
8243 void eFriendly::draw(BITMAP *dest)
8244 {
8245 update_enemy_frame();
8246 enemy::draw(dest);
8247 }
8248
8249 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8250 {
8251 int32_t wpnId = w->id;
8252 int32_t wpnDir = w->dir;
8253
8254 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8255 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8256 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8257 {
8258 shield = false;
8259 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8260
8261 if(get_qr(qr_BRKNSHLDTILES))
8262 o_tile=s_tile;
8263 }
8264
8265 int32_t ret = enemy::takehit(w,realweap);
8266 return ret;
8267 }
8268
8269 void eFriendly::break_shield()
8270 {
8271 if(!shield)
8272 return;
8273
8274 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8275 shield=false;
8276
8277 if(get_qr(qr_BRKNSHLDTILES))
8278 o_tile=s_tile;
8279 }
8280
8281 void eFriendly::repair_shield()
8282 {
8283 if (shield)
8284 return;
8285
8286 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8287 return;
8288
8289 shield = true;
8290
8291 if (get_qr(qr_BRKNSHLDTILES))
8292 {
8293 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8294 else o_tile = d->tile;
8295 }
8296 }
8297
8298
8299 780032 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8300 {
8301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780032 times.
780032 if (ffcactive)
8302 {
8303 removearmosffc(*ffcactive);
8304 return;
8305 }
8306
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8307 {
8308 779016 return;
8309 }
8310
8311 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8312 1016 mapscr* scr = rpos_handle.scr;
8313 1016 ax = TRUNCATE_TILE(ax);
8314 1016 ay = TRUNCATE_TILE(ay);
8315
8316 1016 did_armos=true;
8317 1016 int32_t cd = rpos_handle.pos;
8318 1016 int32_t f = rpos_handle.sflag();
8319 1016 int32_t f2 = rpos_handle.cflag();
8320
8321
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8322 {
8323 840 return;
8324 }
8325
8326 176 scr->data[cd] = scr->undercombo;
8327 176 scr->cset[cd] = scr->undercset;
8328 176 scr->sflag[cd] = 0;
8329
8330
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8331 {
8332 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8333 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8334 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8335 22 sfx(scr->secretsfx);
8336 22 }
8337
8338
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8339 {
8340
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8341 {
8342 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8343 3 sfx(scr->secretsfx);
8344 3 }
8345 3 }
8346
8347 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8348 780032 }
8349
8350 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8351 {
8352 if(did_armos)
8353 {
8354 return;
8355 }
8356
8357 did_armos=true;
8358 ffcdata& ffc = *ffc_handle.ffc;
8359 mapscr* scr = ffc_handle.scr;
8360 auto& cmb = ffc_handle.combo();
8361 int32_t f2 = cmb.flag;
8362
8363 if(cmb.type!=cARMOS)
8364 {
8365 return;
8366 }
8367
8368 ffc_handle.set_data(scr->undercombo);
8369 ffc_handle.set_cset(scr->undercset);
8370
8371 if(f2 == mfARMOS_SECRET)
8372 {
8373 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8374 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8375 sfx(scr->secretsfx);
8376 }
8377
8378 if(f2 == mfARMOS_ITEM)
8379 {
8380 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8381 {
8382 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8383 sfx(scr->secretsfx);
8384 }
8385 }
8386
8387 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8388 }
8389
8390
8391 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8392 461 {
8393 461 fading=fade_flicker;
8394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8395 461 dir=12;
8396 461 movestatus=1;
8397
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8398 461 clk=0;
8399 461 clk4=0;
8400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8401 461 }
8402
8403 117025 bool eGhini::animate(int32_t index)
8404 {
8405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8406
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8407
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8408 50 return Dead(index);
8409
8410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8411 {
8412
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8413 {
8414
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8415 54853 misc=2;
8416
8417
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8418 89752 removearmos(x,y,ffcactivated);
8419 89752 }
8420
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8421 {
8422 425 misc=1;
8423 425 clk3=32;
8424 425 fading=0;
8425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8426 {
8427 activation_counters_ffc[ffcactivated->id] = 0;
8428 removearmosffc(*ffcactivated);
8429 }
8430 else
8431 {
8432 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8433
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8434 {
8435 425 activation_counters[(int)rpos] = 0;
8436 425 removearmos(x,y);
8437 425 }
8438 }
8439 425 }
8440 116975 }
8441
8442 116975 clk4++;
8443
8444 116975 return enemy::animate(index);
8445 117025 }
8446
8447 238808 void eGhini::draw(BITMAP *dest)
8448 {
8449 238808 update_enemy_frame();
8450 238808 enemy::draw(dest);
8451 238808 }
8452
8453 2 void eGhini::kickbucket()
8454 {
8455 2 hp=-1000; // don't call death_sfx()
8456 2 }
8457
8458
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8459 5212 {
8460
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8461 5212 dir=down;
8462 5212 misc=1;
8463 5212 clk=-15;
8464
8465
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8466
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8467
8468 // avoid divide by 0 errors
8469
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8470 dmisc1 = 24;
8471
8472
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8473 dmisc2 = 3;
8474
8475 //nets+760;
8476
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8477 5212 }
8478
8479 1436590 bool eTektite::animate(int32_t index)
8480 {
8481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436590 times.
1436590 if(switch_hooked) return enemy::animate(index);
8482
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8946 times.
✓ Branch 2 taken 8946 times.
✓ Branch 3 taken 1425242 times.
1436590 if(fallclk||drownclk) return enemy::animate(index);
8483
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398575 times.
1425242 if(dying)
8484 26667 return Dead(index);
8485
8486
2/2
✓ Branch 0 taken 1361472 times.
✓ Branch 1 taken 37103 times.
1398575 if(clk==0)
8487 {
8488 37103 removearmos(x,y,ffcactivated);
8489 37103 }
8490
8491
2/2
✓ Branch 0 taken 1057392 times.
✓ Branch 1 taken 341183 times.
1398575 if(get_qr(qr_ENEMIESZAXIS))
8492 {
8493 341183 y=floor_y;
8494 341183 }
8495
8496
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114836 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11960 times.
✓ Branch 9 taken 21878 times.
1398575 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8497 {
8498
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8499 {
8500 case 0: // normal
8501
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8502 {
8503 11233 misc=1;
8504 11233 clk2=32;
8505 11233 }
8506
8507 421702 break;
8508
8509 case 1: // waiting to pounce
8510
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8511 {
8512 20635 int32_t r=zc_oldrand();
8513 20635 misc=2;
8514 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8515 20635 clk3=(r&1)+2; // left or right
8516 20635 clk2start=clk2=(r&31)+10; // flight time
8517
8518
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8519
8520
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8521
8522 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8523 20635 }
8524
8525 345150 break;
8526
8527 case 2: // in flight
8528 493765 move(step);
8529
8530
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8531 {
8532
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8533 {
8534 632 step=0-step;
8535 632 }
8536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8537 {
8538 step=0-step;
8539 }
8540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8541 {
8542 step=0-step;
8543 }
8544
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8545 {
8546 47 step=0-step;
8547 47 }
8548
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8549 {
8550 11 step=0-step;
8551 11 }
8552 234357 }
8553
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8554 {
8555
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8556 {
8557 438 step=0-step;
8558 438 }
8559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8560 {
8561 step=0-step;
8562 }
8563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8564 {
8565 step=0-step;
8566 }
8567
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8568 {
8569 21 step=0-step;
8570 21 }
8571
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8572 {
8573 19 step=0-step;
8574 19 }
8575 244242 }
8576
8577
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8578 {
8579
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8580 {
8581 275 clk3^=1;
8582 275 }
8583
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8584 {
8585 6 clk3^=1;
8586 6 }
8587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8588 {
8589 clk3^=1;
8590 }
8591
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8592 {
8593 30 clk3^=1;
8594 30 }
8595
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8596 {
8597 12 clk3^=1;
8598 12 }
8599 244331 }
8600 else
8601 {
8602
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8603 {
8604 276 clk3^=1;
8605 276 }
8606
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8607 {
8608 12 clk3^=1;
8609 12 }
8610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8611 {
8612 clk3^=1;
8613 }
8614
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8615 {
8616 5 clk3^=1;
8617 5 }
8618
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8619 {
8620 12 clk3^=1;
8621 12 }
8622 }
8623
8624 493765 --c;
8625
8626
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8627 {
8628 173077 step+=zslongToFix(dmisc3*100);
8629 173077 }
8630
8631 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8632
8633
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8634
8635
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8636
8637 493765 x += (clk3==left) ? -1 : 1;
8638
8639
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8640 {
8641
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8642 {
8643 185 step=0-step;
8644 185 y--;
8645 185 }
8646
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8647 {
8648 12928 clk=misc=0;
8649 12928 } //land and jump again
8650 else
8651 {
8652 5796 misc=1;
8653 5796 clk2=0;
8654 }
8655 18909 }
8656
8657 473505 break;
8658 } // switch
8659 1260617 }
8660
8661
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8662 {
8663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8664 {
8665 int32_t tempy = floor_y;
8666 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8667 floor_y = y;
8668 y=tempy-fakez;
8669 old_y = y;
8670 }
8671 else
8672 {
8673 109977 int32_t tempy = floor_y;
8674
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8675 109977 floor_y = y;
8676 109977 y=tempy-z;
8677 109977 old_y = y;
8678 }
8679 109977 }
8680
8681
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8682 10637 clk=0;
8683
8684 1400977 return enemy::animate(index);
8685 1427644 }
8686
8687 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8688 {
8689
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8690 25191 return;
8691
8692 784259 int32_t tempy=yofs;
8693 784259 int32_t fdiv = frate/4;
8694
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8695
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8696 784259 efrate:((clk>=(frate>>1))?1:0);
8697 784259 flip = 0;
8698 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8699
8700
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8701 {
8702
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8703 {
8704 202531 shadowtile+=f2;
8705 202531 }
8706
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8707 322365 shadowtile+=2;
8708 784259 }
8709 else
8710 {
8711 if(misc==0)
8712 {
8713 shadowtile += f2 ? 1 : 0;
8714 }
8715 else if(misc!=1)
8716 {
8717 ++shadowtile;
8718 }
8719 }
8720
8721 784259 yofs+=8;
8722
8723
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8724 {
8725
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8726 262165 }
8727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8728 784259 enemy::drawshadow(dest,translucent);
8729 784259 yofs=tempy;
8730 809450 }
8731
8732 2052032 void eTektite::draw(BITMAP *dest)
8733 {
8734 2052032 update_enemy_frame();
8735 2052032 enemy::draw(dest);
8736 2052032 }
8737
8738 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8739 732 {
8740
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8741 732 superman=1;
8742 732 dir=8;
8743 732 hxofs=1000;
8744 732 mainguy=false;
8745 732 count_enemy=false;
8746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8747 732 }
8748
8749 280245 bool eItemFairy::animate(int32_t index)
8750 {
8751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8753 return Dead(index);
8754
8755 //if(clk>32)
8756 280245 misc=1;
8757 280245 bool w=watch;
8758 280245 watch=false;
8759 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8760 280245 watch=w;
8761
8762
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8763 {
8764 1516 removearmos(x,y,ffcactivated);
8765 1516 }
8766
8767 280245 return enemy::animate(index);
8768 280245 }
8769
8770 562846 void eItemFairy::draw(BITMAP *dest)
8771 {
8772 //these are here to bypass compiler warnings about unused arguments
8773 562846 dest=dest;
8774 562846 }
8775
8776 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8777 1825 {
8778 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8779
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8780 1825 dir=8;
8781 1825 movestatus=1;
8782 1825 clk=0;
8783
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8784 //nets+720;
8785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8786 1825 }
8787
8788 520615 bool ePeahat::animate(int32_t index)
8789 {
8790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8791
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8792
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8793 {
8794 78 return false;
8795 }
8796
8797
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8798 1030 return Dead(index);
8799
8800
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8801 {
8802 3083 removearmos(x,y,ffcactivated);
8803 3083 }
8804
8805
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8806 263053 misc=1;
8807
8808
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8809
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8810
8811
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8812 {
8813
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8814 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8815 100018 }
8816
8817
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8818 1634 superman=0;
8819 else
8820
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8821 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8822
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8823 {
8824
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8825 264937 }
8826 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8827 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8828
8829
8830
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8831
8832 519507 return enemy::animate(index);
8833 520615 }
8834
8835 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8836 {
8837 334520 int32_t tempy=yofs;
8838 334520 flip = 0;
8839 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8840
8841
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8842 {
8843 246431 yofs+=8;
8844 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8845 246431 }
8846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8847 334520 enemy::drawshadow(dest,translucent);
8848 334520 yofs=tempy;
8849 334520 }
8850
8851 1144330 void ePeahat::draw(BITMAP *dest)
8852 {
8853 1144330 update_enemy_frame();
8854 1144330 enemy::draw(dest);
8855 1144330 }
8856
8857 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8858 {
8859 4136 int32_t wpnId = w->id;
8860 4136 int32_t enemyHitWeapon = w->parentitem;
8861
8862
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8863 return 0;
8864
8865
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8866 // fire boomerang, for nailing peahats
8867
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8868 3343 return 0;
8869
8870 // Time for a kludge...
8871 793 int32_t s = superman;
8872 793 superman = 0;
8873 793 int32_t ret = enemy::takehit(w,realweap);
8874 793 superman = s;
8875
8876 // Anyway...
8877
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8878 {
8879 192 clk2=0;
8880 192 movestatus=0;
8881 192 misc=0;
8882 192 clk=0;
8883 192 step=0;
8884 192 }
8885
8886 793 return ret;
8887 4136 }
8888
8889 // auomatically kill off enemy (for rooms with ringleaders)
8890 void ePeahat::kickbucket()
8891 {
8892 hp=-1000; // don't call death_sfx()
8893 }
8894
8895 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8896 3942 {
8897 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8898
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8899 {
8900 2147 misc=-1; //Line of Sight leevers
8901 2147 clk-=16;
8902 2147 }
8903 3942 clk3 = 0;
8904 //nets+1460;
8905 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8906 3942 submerged = false;
8907
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8908 3942 }
8909
8910 923 bool eLeever::isSubmerged() const
8911 {
8912 923 return misc <= 0;
8913 }
8914
8915 1018478 bool eLeever::animate(int32_t index)
8916 {
8917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8918
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8919 {
8920 355 return enemy::animate(index);
8921 }
8922
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8923 31552 return Dead(index);
8924
8925
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8926 {
8927 44970 removearmos(x,y,ffcactivated);
8928 44970 }
8929
8930
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8931 {
8932
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8933 {
8934 case 0: //line of sight
8935 case 2:
8936
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8937 {
8938 case -1: //submerged
8939 {
8940
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8941
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8942 {
8943 10261 break;
8944 }
8945
8946 114198 int32_t active=0;
8947
8948
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8949 {
8950
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8951 {
8952 225696 ++active;
8953 225696 }
8954 783342 }
8955
8956
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8957 {
8958 1871 misc=0; //activate this one
8959 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8960 1871 }
8961 }
8962 114198 break;
8963
8964 case 0:
8965 {
8966
8967
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8968 {
8969 misc=1;
8970 clk2=0;
8971 }
8972
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8973 {
8974 57 misc = -1;
8975 57 break;
8976 }
8977 49052 int32_t s=0;
8978
8979
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8980 {
8981
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8982 {
8983 7882 ++s;
8984 7882 }
8985 273250 }
8986
8987
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8988 {
8989 7882 break;
8990 }
8991
8992 41170 int32_t d2=zc_oldrand()&1;
8993
8994
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8995 {
8996 26661 d2+=2;
8997 26661 }
8998
8999
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9000 {
9001 2111 misc=1;
9002 2111 clk2=0;
9003 2111 clk=0;
9004 2111 }
9005 }
9006 41170 break;
9007
9008 case 1:
9009
9010
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9011
9012 35464 break;
9013
9014 case 2:
9015
9016
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9017
9018 15780 break;
9019
9020 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9021 case 3:
9022
9023
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9024
9025
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9026
9027
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9028 94963 else move(zslongToFix(dstep*100));
9029
9030 95468 break;
9031
9032 case 4:
9033
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9034
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9035 {
9036 468 misc=5;
9037 468 clk=8;
9038 468 }
9039
9040 4365 break;
9041
9042 case 5:
9043
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9044
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9045
9046 6907 break;
9047 } // switch(misc)
9048
9049 337868 break;
9050
9051 default: //random
9052 // step=d->misc3/100.0;
9053
9054 473814 step=zslongToFix(dmisc3*100);
9055
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9056 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9057 {
9058 if (clk2 < 48) clk2+=2;
9059 if (clk2 >= 300) clk2-=2;
9060 }
9061
9062
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9063
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9064
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9065 {
9066 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9067 {
9068 fix_coords();
9069 }*/
9070 289541 misc=3;
9071 289541 step = zslongToFix(dstep*100);
9072 289541 }
9073
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9074
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9075
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9076 {
9077 40151 misc=0;
9078 40151 step=0;
9079 40151 }
9080 274 else clk2=0;
9081
9082
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9083
9084 // variable_walk(d->rate, d->homing, 0);
9085 473814 variable_walk(rate, homing, 0);
9086 473814 } // switch(dmisc1)
9087 811682 }
9088
9089 986571 hxofs=(misc>=2)?0:1000;
9090 986571 return enemy::animate(index);
9091 1018478 }
9092
9093 80892 bool eLeever::canplace(int32_t d2)
9094 {
9095 80892 int32_t nx=HeroX();
9096 80892 int32_t ny=HeroY();
9097
9098
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9099 52400 else nx=TRUNCATE_TILE(nx);
9100
9101
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9102 {
9103 case up:
9104
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9105 14174 break;
9106
9107 case down:
9108
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9109
9110
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9111
9112 14318 break;
9113
9114 case left:
9115
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9116 26181 break;
9117
9118 case right:
9119
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9120
9121
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9122
9123 26219 break;
9124 }
9125
9126
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9127 69464 return false;
9128
9129
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9130
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9131 9317 return false;
9132
9133 2111 x=nx;
9134 2111 y=ny;
9135 2111 dir=d2^1;
9136 2111 return true;
9137 80892 }
9138
9139 1024382 void eLeever::draw(BITMAP *dest)
9140 {
9141 // cs=d->cset;
9142 1024382 cs=dcset;
9143 1024382 update_enemy_frame();
9144
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9145 {
9146
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9147 {
9148 case -1:
9149 case 0:
9150 386939 return;
9151 }
9152 637088 }
9153
9154 637443 enemy::draw(dest);
9155 1024382 }
9156
9157 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9158 998 {
9159 998 hashero=false;
9160 //nets+1000;
9161
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9162 998 }
9163
9164 504762 bool eWallM::animate(int32_t index)
9165 {
9166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9167
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9168 {
9169 return enemy::animate(index);
9170 }
9171
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9172 9856 return Dead(index);
9173
9174
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9175 {
9176 30976 removearmos(x,y,ffcactivated);
9177 30976 }
9178
9179 494906 hxofs=1000;
9180
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9181 {
9182
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9183 {
9184 211789 int32_t wall=hero_on_wall();
9185 211789 int32_t wallm_cnt=0;
9186
9187
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9188
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9189 {
9190 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9191
9192
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9193 {
9194 13366 ++wallm_cnt;
9195 13366 }
9196 1013091 }
9197
9198
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9199 {
9200 841 --wall;
9201 841 misc=1; //emerging from the wall?
9202 841 clk2=0;
9203 841 clk3=wall^1;
9204 841 wallm_load_clk=frame;
9205
9206
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9207 {
9208
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9209 91 dir=right;
9210 else
9211 423 dir=left;
9212 514 }
9213 else
9214 {
9215
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9216 66 dir=down;
9217 else
9218 261 dir=up;
9219 }
9220
9221
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9222 {
9223 case up:
9224 231 y=0;
9225 231 break;
9226
9227 case down:
9228 283 y=160;
9229 283 break;
9230
9231 case left:
9232 223 x=0;
9233 223 break;
9234
9235 case right:
9236 104 x=240;
9237 104 break;
9238 }
9239
9240
9241
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9242 {
9243 case up:
9244 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9245 261 flip=wall&1;
9246 261 break;
9247
9248 case down:
9249 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9250 66 flip=((wall&1)^1)+2;
9251 66 break;
9252
9253 case left:
9254 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9255 423 flip=(wall==up?2:0)+1;
9256 423 break;
9257
9258 case right:
9259 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9260 91 flip=(wall==up?2:0);
9261 91 break;
9262 }
9263
9264 841 }
9265 211789 }
9266 377174 }
9267 else
9268 117732 wallm_crawl();
9269
9270 494906 return enemy::animate(index);
9271 504762 }
9272
9273 117732 void eWallM::wallm_crawl()
9274 {
9275 117732 bool w=watch;
9276 117732 hxofs=0;
9277
9278
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9279 {
9280 810 return;
9281 }
9282
9283 // if(dying || watch || (!hashero && stunclk))
9284
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9285 {
9286 14546 return;
9287 }
9288
9289 102376 watch=false;
9290 102376 ++clk2;
9291 // Misc1: slightly different movement
9292 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9293
9294 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9296
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9297 {
9298 4491 --clk2;
9299 4491 }
9300
9301
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9302 {
9303 case 1:
9304 case 2:
9305 52852 zc_swap(dir,clk3);
9306 52852 move(step);
9307 52852 zc_swap(dir,clk3);
9308 52852 break;
9309
9310 case 3:
9311 case 4:
9312 case 5:
9313
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9314 {
9315 4491 watch=w;
9316 4491 return;
9317 }
9318
9319 34905 move(step);
9320 34905 break;
9321
9322 case 6:
9323 case 7:
9324 9984 zc_swap(dir,clk3);
9325 9984 dir^=1;
9326 9984 move(step);
9327 9984 dir^=1;
9328 9984 zc_swap(dir,clk3);
9329 9984 break;
9330
9331 default:
9332 144 misc=0;
9333 144 break;
9334 }
9335
9336 97885 watch=w;
9337 117732 }
9338
9339 9 void eWallM::grabhero()
9340 {
9341 9 hashero=true;
9342 9 superman=1;
9343 9 }
9344
9345 507147 void eWallM::draw(BITMAP *dest)
9346 {
9347 507147 dummy_bool[1]=hashero;
9348 507147 update_enemy_frame();
9349
9350
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9351 {
9352 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9353 129181 }
9354
9355 // enemy::draw(dest);
9356 // tile = clk&8 ? 128:129;
9357 507147 }
9358
9359 bool eWallM::isSubmerged() const
9360 {
9361 return ( !misc );
9362 }
9363
9364 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9365 1640 {
9366
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9367
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9368
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9369 {
9370
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9371 166 }
9372
9373 1640 mainguy=false;
9374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9375 //nets+420;
9376 1640 dummy_int[1]=0;
9377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9378 1640 }
9379
9380 1042165 bool eTrap::animate(int32_t index)
9381 {
9382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9383
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9384
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9385 21654 return enemy::animate(index);
9386
9387
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9388 {
9389 64549 removearmos(x,y,ffcactivated);
9390 64549 }
9391
9392
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9393 {
9394 701302 ox = x;
9395 701302 oy = y;
9396 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9397 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9398
9399
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9400 {
9401 108261 dir=down;
9402 108261 }
9403
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9404 {
9405 259792 dir=right;
9406 259792 }
9407
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9408 {
9409 78523 dir=up;
9410 78523 }
9411 else
9412 {
9413 254726 dir=left;
9414 }
9415
9416 701302 int32_t d2=lined_up(15,true);
9417
9418
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9419
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 173368 times.
405932 ((d2>down) && (dmisc1==2)) ||
9420
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 81901 times.
173368 ((d2>right) && (!dmisc1)) ||
9421
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
268970 ((d2<l_up) && (dmisc1==4)) ||
9422
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 268970 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
125023 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9423
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
268970 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9424 {
9425 2521777 d2=-1;
9426 2521777 }
9427
9428
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 411624 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
432332 if(d2!=-1 && trapmove(d2))
9429 {
9430 2115 dir=d2;
9431 2115 misc=1;
9432 2115 clk2=(dir==down)?3:0;
9433 2115 }
9434 432332 }
9435
9436
2/2
✓ Branch 0 taken 662006 times.
✓ Branch 1 taken 89535 times.
751541 if(misc==1) // charging
9437 {
9438 89535 clk2=(clk2+1)&3;
9439 89535 step=(clk2==3)?1:2;
9440
9441
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9442 {
9443 1909 misc=2;
9444
9445
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9446 {
9447 1909 dir=dir^1;
9448 1909 }
9449 else
9450 {
9451 dir=dir^3;
9452 }
9453 1909 }
9454 else
9455 {
9456 87626 sprite::move(step);
9457 }
9458 89535 }
9459
9460
2/2
✓ Branch 0 taken 517843 times.
✓ Branch 1 taken 233698 times.
751541 if(misc==2) // retreating
9461 {
9462 233698 step=(++clk2&1)?1:0;
9463
9464
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9465 {
9466 case up:
9467
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9468 38739 else sprite::move(step);
9469
9470 38739 break;
9471
9472 case left:
9473
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9474 80555 else sprite::move(step);
9475
9476 80555 break;
9477
9478 case down:
9479
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9480 28905 else sprite::move(step);
9481
9482 28905 break;
9483
9484 case right:
9485
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9486 84176 else sprite::move(step);
9487
9488 84176 break;
9489
9490 case l_up:
9491 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9492 else sprite::move(step);
9493
9494 break;
9495
9496 case r_up:
9497 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9498 else sprite::move(step);
9499
9500 break;
9501
9502 case l_down:
9503 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9504 else sprite::move(step);
9505
9506 break;
9507
9508 case r_down:
9509 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9510 else sprite::move(step);
9511
9512 break;
9513 trap_rest:
9514 {
9515 1323 x=ox;
9516 1323 y=oy;
9517 1323 misc=0;
9518 }
9519 1323 }
9520 233698 }
9521
9522 751541 return enemy::animate(index);
9523 773195 }
9524
9525 110243 bool eTrap::trapmove(int32_t ndir)
9526 {
9527
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9528 {
9529 80479 mapscr* scr = get_scr(screen_spawned);
9530
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9531 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9532
9533 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9534 }
9535
9536
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9537 4730 return false;
9538
9539
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9540 return false;
9541
9542
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9543 return false;
9544
9545
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9546 return false;
9547
9548
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9549 4722 return false;
9550
9551
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9552 713 return false;
9553
9554
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9555 return false;
9556
9557
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9558 return false;
9559
9560
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9561 return false;
9562
9563
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9564 return false;
9565
9566 19599 return true;
9567 110243 }
9568
9569 88731 bool eTrap::clip()
9570 {
9571
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9572 {
9573
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9574 {
9575 case up:
9576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9577
9578 5792 break;
9579
9580 case down:
9581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9582
9583 8656 break;
9584
9585 case left:
9586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9587
9588 16039 break;
9589
9590 case right:
9591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9592
9593 15222 break;
9594
9595 case l_up:
9596 if(y<=0||x<=0) return true;
9597
9598 break;
9599
9600 case l_down:
9601 if(y>=world_h-16||x<=0) return true;
9602
9603 break;
9604
9605 case r_up:
9606 if(y<=0||x>=world_w-16) return true;
9607
9608 break;
9609
9610 case r_down:
9611 if(y>=world_h-16||x>=world_w-16) return true;
9612
9613 break;
9614 }
9615
9616 45709 return false;
9617 }
9618 else
9619 {
9620
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9621 {
9622 case up:
9623
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9624
9625 4695 break;
9626
9627 case down:
9628
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9629
9630 5253 break;
9631
9632 case left:
9633
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9634
9635 16376 break;
9636
9637 case right:
9638
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9639
9640 15593 break;
9641
9642 case l_up:
9643 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9644
9645 break;
9646
9647 case l_down:
9648 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9649
9650 break;
9651
9652 case r_up:
9653 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9654
9655 break;
9656
9657 case r_down:
9658 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9659
9660 break;
9661 }
9662
9663 41917 return false;
9664 }
9665 88731 }
9666
9667 1061079 void eTrap::draw(BITMAP *dest)
9668 {
9669 1061079 update_enemy_frame();
9670 1061079 enemy::draw(dest);
9671 1061079 }
9672
9673 5705 int32_t eTrap::takehit(weapon*,weapon*)
9674 {
9675 5705 return 0;
9676 }
9677
9678 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9679 832 {
9680 832 lasthit=-1;
9681 832 lasthitclk=0;
9682 832 mainguy=false;
9683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9684
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9685
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9686 {
9687
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9688 399 }
9689 else
9690 {
9691
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9692 }
9693
9694
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9695 {
9696
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9697 72 }
9698
9699 //nets+((id==eTRAP_LR)?540:520);
9700 832 dummy_int[1]=0;
9701
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9702 832 }
9703
9704 346559 bool eTrap2::animate(int32_t index)
9705 {
9706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9707
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9708
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9709 11026 return enemy::animate(index);
9710
9711
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9712 {
9713 21385 removearmos(x,y,ffcactivated);
9714 21385 }
9715
9716
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9717 {
9718
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9719 {
9720 11074 --lasthitclk;
9721 11074 }
9722 else
9723 {
9724 113252 lasthit=-1;
9725 }
9726
9727 124326 bool hitenemy=false;
9728
9729
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9730 {
9731
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9732 {
9733
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9734 {
9735 3669 lasthit=j;
9736 3669 lasthitclk=10;
9737 3669 hitenemy=true;
9738 3669 guys.spr(j)->lasthit=index;
9739 3669 guys.spr(j)->lasthitclk=10;
9740 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9741 3669 }
9742 730351 }
9743 864860 }
9744
9745
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9746 {
9747
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9748 {
9749 3155 lasthit=-1;
9750 3155 lasthitclk=0;
9751 3155 }
9752
9753
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9754 362 sfx(WAV_ZN1TAP,pan(x));
9755
9756 5986 dir=dir^1;
9757 5986 }
9758
9759 124326 sprite::move(step);
9760 124326 }
9761 else
9762 {
9763
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9764 {
9765
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9766 1521 sfx(WAV_ZN1TAP,pan(x));
9767
9768 6919 dir=dir^1;
9769 6919 }
9770
9771 211207 sprite::move(step);
9772 }
9773
9774 335533 return enemy::animate(index);
9775 346559 }
9776
9777 341519 bool eTrap2::trapmove(int32_t ndir)
9778 {
9779 341519 mapscr* scr = get_scr(screen_spawned);
9780
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9781 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9782
9783 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9784 341519 }
9785
9786 328290 bool eTrap2::clip()
9787 {
9788
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9789 {
9790 case up:
9791
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9792
9793 88320 break;
9794
9795 case down:
9796
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9797
9798 89029 break;
9799
9800 case left:
9801
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9802
9803 75153 break;
9804
9805 case right:
9806
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9807
9808 75788 break;
9809 }
9810
9811 328290 return false;
9812 328290 }
9813
9814 350933 void eTrap2::draw(BITMAP *dest)
9815 {
9816 350933 update_enemy_frame();
9817 350933 enemy::draw(dest);
9818 350933 }
9819
9820 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9821 {
9822 3169 return 0;
9823 }
9824
9825 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9826 354 {
9827 //do not show "enemy appering" anim -DD
9828 354 clk=0;
9829 354 mainguy=false;
9830 354 clk2=-14;
9831 //Enemy Editor Size Tab
9832
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9833 //nets+1640;
9834 354 }
9835
9836 354 void eRock::init_size_flags()
9837 {
9838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9839 354 else hxofs = -2;
9840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9841 354 else hyofs = -2;
9842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9843 354 else hit_width = 20;
9844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9845 354 else hit_height = 20;
9846
9847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9848
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9850
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9851
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9852 {
9853 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9854 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9855 }
9856
9857
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9858 354 }
9859
9860 121997 bool eRock::animate(int32_t index)
9861 {
9862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9863
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9865 return Dead(index);
9866
9867
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9868 {
9869 8376 removearmos(x,y,ffcactivated);
9870 8376 }
9871
9872
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9873 {
9874 697 x=zc_oldrand()&0xF0;
9875 697 y=0;
9876 697 clk3=0;
9877 697 clk2=zc_oldrand()&15;
9878 697 }
9879
9880
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9881 {
9882
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9883 {
9884 3430 dir=zc_oldrand()&1;
9885
9886
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9887
9888
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9889 3430 }
9890
9891
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9892 {
9893 95993 x += dir ? 1 : -1; //right, left
9894 95993 dummy_int[1]=dir;
9895
9896
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9897 {
9898 6852 y-=2; //up
9899 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9900 6852 }
9901
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9902 {
9903 10208 y--; //up
9904 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9905 10208 }
9906
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9907 {
9908 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9909 10135 }
9910
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9911 {
9912 10058 y++; //down
9913 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9914 10058 }
9915 else
9916 {
9917 58740 y+=2; //down
9918 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9919 }
9920
9921 95993 ++clk3;
9922 95993 }
9923
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9924 2761 clk3=0; // next bounce
9925 else
9926 423 clk2 = -(zc_oldrand()&63); // back to top
9927 99177 }
9928
9929 121997 return enemy::animate(index);
9930 121997 }
9931
9932 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9933 {
9934
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9935 {
9936 44250 int32_t tempy=yofs;
9937 44250 flip = 0;
9938 44250 int32_t fdiv = frate/4;
9939
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9940
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9941 44250 efrate:((clk>=(frate>>1))?1:0);
9942 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9943
9944 44250 yofs+=8;
9945
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9947 44250 sprite::drawshadow(dest, translucent);
9948 44250 yofs=tempy;
9949 44250 }
9950 51441 }
9951
9952 122078 void eRock::draw(BITMAP *dest)
9953 {
9954
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9955 {
9956 105043 int32_t tempdir=dir;
9957 105043 dir=dummy_int[2];
9958 105043 update_enemy_frame();
9959 105043 enemy::draw(dest);
9960 105043 dir=tempdir;
9961 105043 }
9962 122078 }
9963
9964 1014 int32_t eRock::takehit(weapon*,weapon*)
9965 {
9966 1014 return 0;
9967 }
9968
9969 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9970 30 {
9971 30 clk=0;
9972 30 mainguy=false;
9973 30 clk2=-14;
9974
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9975 //nets+1680;
9976 30 }
9977
9978 4440 bool eBoulder::animate(int32_t index)
9979 {
9980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9981
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9983 return Dead(index);
9984
9985
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9986 {
9987 290 removearmos(x,y,ffcactivated);
9988 290 }
9989
9990 zfix *vert;
9991
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9992
9993
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9994 {
9995 32 x=zc_oldrand()&0xF0;
9996 32 y=-32;
9997 32 clk3=0;
9998 32 clk2=zc_oldrand()&15;
9999 32 }
10000
10001
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10002 {
10003
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10004 {
10005 131 dir=zc_oldrand()&1;
10006
10007
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10008
10009
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10010 131 }
10011
10012
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10013 {
10014 3487 x += dir ? 1 : -1; //right, left
10015 3487 dummy_int[1]=dir;
10016
10017
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10018 {
10019 261 y-=2; //up
10020 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10021 261 }
10022
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10023 {
10024 382 y--; //up
10025 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10026 382 }
10027
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10028 {
10029 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10030 376 }
10031
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10032 {
10033 367 y++; //down
10034 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10035 367 }
10036 else
10037 {
10038 2101 y+=2; //down
10039 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10040 }
10041
10042 3487 ++clk3;
10043 3487 }
10044
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10045 101 clk3=0; // next bounce
10046 else
10047 10 clk2 = -(zc_oldrand()&63); // back to top
10048 3598 }
10049
10050 4440 return enemy::animate(index);
10051 4440 }
10052
10053 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10054 {
10055
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10056 {
10057 3868 int32_t tempy=yofs;
10058 3868 flip = 0;
10059 3868 int32_t f2=((clk<<2)/frate)<<1;
10060 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10061
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10062
10063 3868 yofs+=8;
10064 3868 xofs-=8;
10065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10066 3868 sprite::drawshadow(dest, translucent);
10067 3868 xofs+=16;
10068 3868 ++shadowtile;
10069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10070 3868 sprite::drawshadow(dest, translucent);
10071 3868 yofs+=16;
10072 3868 shadowtile+=20;
10073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10074 3868 sprite::drawshadow(dest, translucent);
10075 3868 xofs-=16;
10076 3868 --shadowtile;
10077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10078 3868 sprite::drawshadow(dest, translucent);
10079 3868 xofs+=8;
10080 3868 yofs=tempy;
10081 3868 }
10082 4440 }
10083
10084 4440 void eBoulder::draw(BITMAP *dest)
10085 {
10086
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10087 {
10088 3868 int32_t tempdir=dir;
10089 3868 dir=dummy_int[2];
10090 3868 update_enemy_frame();
10091 3868 dir=tempdir;
10092 3868 xofs-=8;
10093 3868 yofs-=8;
10094 3868 drawblock(dest,15);
10095 3868 xofs+=8;
10096 3868 yofs+=8;
10097 // enemy::draw(dest);
10098 3868 }
10099 4440 }
10100
10101 30 void eBoulder::init_size_flags()
10102 {
10103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10104 30 else hxofs = -10;
10105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10106 30 else hyofs = -10;
10107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10108 30 else hit_width = 36;
10109
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10110 30 else hit_height = 36;
10111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10112 30 else hzsz = 16; //can't be jumped
10113
10114
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10117
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10118
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10119 {
10120 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10121 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10122 }
10123
10124
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10125 30 }
10126
10127 int32_t eBoulder::takehit(weapon*,weapon*)
10128 {
10129 return 0;
10130 }
10131
10132 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10133
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10134 4429 {
10135 /* fixing
10136 hp=1;
10137 */
10138 4429 mainguy=false;
10139
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10140 4429 hclk=clk; // the "no fire" range
10141 4429 clk=0;
10142 4429 clk3=96;
10143 4429 timer=0;
10144
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10145 {
10146 4415 superman=1;
10147 4415 hxofs=1000;
10148 4415 }
10149
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10150 4429 }
10151
10152 2504746 bool eProjectile::animate(int32_t index)
10153 {
10154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10155
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10156
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10157 {
10158 12326 removearmos(x,y,ffcactivated);
10159 12326 }
10160
10161 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10162 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10163
10164
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10165 {
10166 403631 dir=down;
10167 403631 }
10168
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10169 {
10170 916920 dir=right;
10171 916920 }
10172
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10173 {
10174 358900 dir=up;
10175 358900 }
10176 else
10177 {
10178 825295 dir=left;
10179 }
10180
10181
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10182 {
10183
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10184 {
10185
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10186 {
10187 563 unsigned r=zc_oldrand();
10188
10189
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10190 {
10191 6 timer=zc_oldrand()%50+50;
10192 6 }
10193 563 }
10194
10195
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10196 {
10197
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10198 {
10199 119 FireBreath(false);
10200 119 }
10201
10202
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10203 {
10204 6 clk3=0;
10205 6 }
10206 489 }
10207 1046 }
10208
10209 else // Not breath type
10210 {
10211 1197433 unsigned r=zc_oldrand();
10212
10213
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10214 {
10215 17542 FireWeapon();
10216
10217
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10218
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10219 {
10220
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10221 {
10222 909 x-=4;
10223 909 FireWeapon();
10224 909 x+=4;
10225 909 }
10226 14854 }
10227
10228 17542 clk3=0;
10229 17542 }
10230 }
10231 1198479 }
10232
10233 2504746 return enemy::animate(index);
10234 2504746 }
10235
10236 2520335 void eProjectile::draw(BITMAP *dest)
10237 {
10238 2520335 update_enemy_frame();
10239 2520335 enemy::draw(dest);
10240 2520335 }
10241
10242 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10243 533 {
10244 533 hxofs=1000;
10245 533 }
10246
10247 249811 void eTrigger::draw(BITMAP *dest)
10248 {
10249 249811 update_enemy_frame();
10250 249811 enemy::draw(dest);
10251 249811 }
10252
10253 void eTrigger::death_sfx()
10254 {
10255 //silent death
10256 }
10257
10258 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10259 5 {
10260 5 o_tile+=wpnsbuf[iwNPCs].tile;
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10262 5 SIZEflags = d->SIZEflags;
10263
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10264 5 }
10265
10266 75 bool eNPC::animate(int32_t index)
10267 {
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10269
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10270 70 return Dead(index);
10271
10272
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10273 {
10274 removearmos(x,y,ffcactivated);
10275 }
10276
10277
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10278 {
10279 case 0:
10280 {
10281 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10282 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10283
10284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10285 {
10286 dir=down;
10287 }
10288
10289
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10290 {
10291 5 dir=right;
10292 5 }
10293 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10294 {
10295 dir=up;
10296 }
10297 else
10298 {
10299 dir=left;
10300 }
10301 }
10302 5 break;
10303
10304 case 1:
10305 halting_walk(rate, homing, 0, hrate, 48);
10306
10307 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10308 {
10309 newdir(rate, homing, 0);
10310 clk2=48;
10311 ++misc;
10312 }
10313
10314 if(clk2==0)
10315 misc=0;
10316
10317 break;
10318 }
10319
10320 5 return enemy::animate(index);
10321 75 }
10322
10323 75 void eNPC::draw(BITMAP *dest)
10324 {
10325 75 update_enemy_frame();
10326 75 enemy::draw(dest);
10327 75 }
10328
10329 int32_t eNPC::takehit(weapon*,weapon*)
10330 {
10331 return 0;
10332 }
10333
10334 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10335 94 {
10336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10337 {
10338 94 o_tile=clk;
10339 94 cs=id>>12;
10340 94 }
10341
10342 94 id=id&0xFFF;
10343 94 clk=0;
10344
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10345 94 mainguy=false;
10346 94 SIZEflags = d->SIZEflags;
10347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10348 94 }
10349
10350 81 void eSpinTile::facehero()
10351 {
10352
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10353 {
10354
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10355 1 dir = up;
10356 else
10357 dir = down;
10358 1 }
10359 else
10360 {
10361 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10362 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10363
10364
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10365 {
10366 12 dir=l_down;
10367 12 }
10368
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10369 {
10370 1 dir=down;
10371 1 }
10372
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10373 {
10374 12 dir=r_down;
10375 12 }
10376
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10377 {
10378 6 dir=right;
10379 6 }
10380
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10381 {
10382 17 dir=r_up;
10383 17 }
10384
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10385 {
10386 8 dir=up;
10387 8 }
10388
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10389 {
10390 6 dir=l_up;
10391 6 }
10392 else
10393 {
10394 18 dir=left;
10395 }
10396 }
10397 81 }
10398
10399
10400 15539 bool eSpinTile::animate(int32_t index)
10401 {
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10403
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10404
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10405 {
10406 1152 return Dead(index);
10407 }
10408
10409
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10410 {
10411 1241 removearmos(x,y,ffcactivated);
10412 1241 }
10413
10414 14387 ++misc;
10415
10416
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10417 {
10418 81 facehero();
10419 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10420 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10421 81 angular=true;
10422 81 angle=ddir;
10423 81 step=zslongToFix(dstep*100);
10424 81 }
10425
10426
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10427 52 kickbucket();
10428
10429 14387 sprite::move(step);
10430 14387 return enemy::animate(index);
10431 15539 }
10432
10433 15457 void eSpinTile::draw(BITMAP *dest)
10434 {
10435 15457 update_enemy_frame();
10436 15457 y-=(misc>>4);
10437 15457 yofs+=2;
10438 15457 enemy::draw(dest);
10439 15457 yofs-=2;
10440 15457 y+=(misc>>4);
10441 15457 }
10442
10443 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10444 {
10445 15457 flip = 0;
10446 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10447 15457 yofs+=4;
10448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10449 15457 enemy::drawshadow(dest, translucent);
10450 15457 yofs-=4;
10451 15457 }
10452
10453 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10454 2797 {
10455 //these are here to bypass compiler warnings about unused arguments
10456 2797 Clk=Clk;
10457 2797 mainguy=false;
10458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10459
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10460 2797 }
10461
10462 628398 void eZora::facehero()
10463 {
10464
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10465 {
10466 10785 dir=(Hero.y+8<y)?up:down;
10467 10785 }
10468 else
10469 {
10470 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10471 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10472
10473
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10474 {
10475 78554 dir=l_down;
10476 78554 }
10477
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10478 {
10479 45075 dir=down;
10480 45075 }
10481
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10482 {
10483 74214 dir=r_down;
10484 74214 }
10485
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10486 {
10487 115362 dir=right;
10488 115362 }
10489
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10490 {
10491 80403 dir=r_up;
10492 80403 }
10493
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10494 {
10495 41943 dir=up;
10496 41943 }
10497
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10498 {
10499 74672 dir=l_up;
10500 74672 }
10501 else
10502 {
10503 107390 dir=left;
10504 }
10505 }
10506 628398 }
10507
10508 857137 bool eZora::animate(int32_t index)
10509 {
10510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10511
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10512 2854 return Dead(index);
10513
10514
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10515 {
10516 5746 removearmos(x,y,ffcactivated);
10517 5746 }
10518
10519
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10520 {
10521 35 clock_zoras.push_back({screen_spawned, id});
10522 35 return true;
10523 }
10524
10525
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10526 {
10527 628398 facehero();
10528 628398 }
10529
10530
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10531 {
10532 case 0: // reposition him
10533 {
10534 6482 int32_t t=0;
10535 6482 int32_t pos2=zc_oldrand()%160 + 16;
10536 6482 bool placed=false;
10537
10538
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10539 {
10540 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10541 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10542 26366 mapscr* s = get_scr(screen_spawned);
10543
10544 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10545
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10546
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10547
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10548 {
10549 5681 x=sx;
10550 5681 y=sy;
10551
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10552 5681 hxofs=1000; // avoid hit detection
10553 5681 stunclk=0;
10554 5681 placed=true;
10555 5681 }
10556
10557 38464 pos2+=19;
10558
10559
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10560 4563 pos2-=160;
10561
10562 38464 ++t;
10563 }
10564
10565
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10566 65 return true;
10567
10568 }
10569 5681 break;
10570
10571 case 35:
10572
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10573 {
10574 1361 dir=(Hero.y+8<y)?up:down;
10575 1361 }
10576
10577 5232 hxofs=0;
10578 5232 break;
10579
10580 case 35+19:
10581 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10582 4993 sfx(wpnsfx(wpn),pan(x));
10583 4993 break;
10584
10585 case 35+66:
10586 4190 hxofs=1000;
10587 4190 break;
10588
10589 case 198:
10590 2977 clk=-1;
10591 2977 break;
10592 }
10593
10594 853447 return enemy::animate(index);
10595 856401 }
10596
10597 867086 void eZora::draw(BITMAP *dest)
10598 {
10599
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10600 20009 return;
10601
10602 847077 update_enemy_frame();
10603 847077 enemy::draw(dest);
10604 867086 }
10605
10606 867318 bool eZora::isSubmerged() const
10607 {
10608 867318 return clk < 3;
10609 }
10610
10611
3/6
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
100514 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10612 50257 {
10613 50257 multishot= timer = fired = dashing = 0;
10614 50257 hashero = false;
10615 50257 dummy_bool[0]=false;
10616
4/8
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50257 times.
✗ Branch 7 not taken.
50257 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10617
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49255 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50257 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10618 {
10619
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10620
10621
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10622 519 }
10623
10624
3/4
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49255 times.
50257 if(flags & guy_fade_flicker)
10625 {
10626 1002 clk=0;
10627 1002 superman = 1;
10628 1002 fading=fade_flicker;
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10630 1002 dir=down;
10631
10632
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10633
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10634 1002 }
10635
3/4
✓ Branch 0 taken 49255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49122 times.
✓ Branch 3 taken 133 times.
49255 else if(flags & guy_fade_instant)
10636 {
10637 133 clk=0;
10638 133 }
10639
10640
1/2
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
50257 shadowdistance = 0;
10641 50257 clk4 = clk5 = 0;
10642 //nets+2380;
10643
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50255 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50257 if (SIZEflags != 0) init_size_flags();;
10644 50257 }
10645
10646 15823224 bool eStalfos::animate(int32_t index)
10647 {
10648
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15822968 times.
15823224 if(switch_hooked) return enemy::animate(index);
10649
3/4
✓ Branch 0 taken 15822542 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15822542 times.
15822968 if(fallclk||drownclk)
10650 {
10651 426 return enemy::animate(index);
10652 }
10653
2/2
✓ Branch 0 taken 353022 times.
✓ Branch 1 taken 15469520 times.
15822542 if(dying)
10654 {
10655
2/2
✓ Branch 0 taken 352974 times.
✓ Branch 1 taken 48 times.
353022 if(hashero)
10656 {
10657 48 Hero.setEaten(0);
10658 48 hashero=false;
10659 48 }
10660
10661
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316990 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
353022 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10662 {
10663 187 hp=-1000;
10664
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10665 187 Ewpns.add(ew);
10666 187 ew->fakez = fakez;
10667
10668
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10669 {
10670 187 ew->step=0;
10671 187 ew->id=wpn;
10672 187 ew->misc=50;
10673 187 ew->clk=48;
10674 187 }
10675
10676 187 fired=true;
10677 187 }
10678
6/6
✓ Branch 0 taken 156368 times.
✓ Branch 1 taken 196467 times.
✓ Branch 2 taken 130316 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130298 times.
✓ Branch 5 taken 18 times.
352835 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10679 {
10680
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10681 {
10682 1 int32_t wpn2 = wpn+dmisc3;
10683
10684
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10685 {
10686 wpn2=wpn;
10687 }
10688
10689 1 dummy_bool[0]=true;
10690 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10691 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10692 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10693 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10694 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10695 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10696 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10697 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10698 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10699 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10700 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10701 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10702 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10703 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10704 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10705 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10706 1 sfx(wpnsfx(wpn2),pan(x));
10707 1 }
10708 18 }
10709
10710 353022 KillWeapon();
10711 353022 return Dead(index);
10712 }
10713 //vire split
10714 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10715 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10716
13/14
✓ Branch 0 taken 21143 times.
✓ Branch 1 taken 15448377 times.
✓ Branch 2 taken 21143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20792 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14276473 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15469520 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10717 {
10718 1677 stop_bgsfx(index);
10719 1677 int32_t kids = guys.Count();
10720 1677 int32_t id2=dmisc3;
10721
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10722 {
10723
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10724 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10725 3307 }
10726
10727
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10728 {
10729 1 int guycarryingitem = guys.Count()-1;
10730 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10731 1 itemguy = false;
10732 1 }
10733
10734
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10735 {
10736 17 Hero.setEaten(0);
10737 17 hashero=false;
10738 17 }
10739
10740
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10741 323 sfx(deadsfx,pan(x));
10742
10743 1677 return true;
10744 }
10745
10746
2/2
✓ Branch 0 taken 71161 times.
✓ Branch 1 taken 15396682 times.
15467843 if(fading)
10747 {
10748
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69933 times.
71161 if(++clk4 > 60)
10749 {
10750 1228 clk4=0;
10751 1228 superman=0;
10752 1228 fading=0;
10753
10754
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10755 {
10756 //if a custom size (not 16px by 16px)
10757
10758 //if a custom size (not 16px by 16px)
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10760 removearmosffc(*ffcactivated);
10761 else
10762 {
10763
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10764 {
10765 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10766 for(int32_t dx = 0; dx < tysz; dx ++)
10767 {
10768 for(int32_t dy = 0; dy < tysz; dy++)
10769 {
10770 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10771 did_armos = false;
10772 }
10773 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10774 did_armos = false;
10775 }
10776 for(int32_t dy = 0; dy < tysz; dy ++)
10777 {
10778 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10779 did_armos = false;
10780 }
10781 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10782 }
10783 967 else removearmos(x,y);
10784 }
10785
10786 967 }
10787
10788 1228 clk2=0;
10789
10790 1228 newdir();
10791 1228 }
10792 69933 else return enemy::animate(index);
10793 1228 }
10794
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15248273 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15396682 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10795 9555 removearmos(x,y,ffcactivated);
10796
10797
10798
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15390703 times.
15397910 if(hashero)
10799 {
10800 7207 Hero.setX(x);
10801 7207 Hero.setY(y);
10802 7207 ++clk2;
10803
10804
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10805 {
10806
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10807 {
10808 case e7tEATITEMS:
10809 {
10810
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10811 {
10812
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10813 22 game->set_item(i, false);
10814 5632 }
10815
10816 22 break;
10817 }
10818
10819 case e7tEATMAGIC:
10820 game->change_dmagic(-1*game->get_magicdrainrate());
10821 break;
10822
10823 case e7tEATRUPEES:
10824 game->change_drupy(-1);
10825 break;
10826 }
10827
10828 899 clk2=0;
10829 899 }
10830
10831
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10832 6661 --clk;
10833 7207 }
10834
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14341830 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15390703 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10835 {
10836 // Movement engine
10837
6/6
✓ Branch 0 taken 839470 times.
✓ Branch 1 taken 14118397 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14114936 times.
✓ Branch 5 taken 59 times.
14957867 if(clk>=0) switch(id>>12)
10838 {
10839 case 0: // Normal movement
10840
10841 /*
10842 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10843 {
10844 // Overloading clk4 (Tribble clock) here...
10845 step=17/100.0;
10846 if(clk4<32) misc=1;
10847 else if(clk4<48) misc=2;
10848 else if(clk4<300) { misc=3; step = dstep/100.0; }
10849 else if(clk4<316) misc=2;
10850 else if(clk4<412) misc=1;
10851 else if(clk4<540) { misc=0; step=0; }
10852 else clk4=0;
10853 if(clk4==48) clk=0;
10854 hxofs=(misc>=2)?0:1000;
10855 if (dmisc9==e9tLEEVER)
10856 variable_walk(rate, homing, 0);
10857 else
10858 variable_walk_8(rate, homing, 4, 0);
10859 break;
10860 }
10861 */
10862
4/4
✓ Branch 0 taken 13735902 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13318826 times.
14114936 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10863 {
10864 796110 vire_hop();
10865 796110 break;
10866 }
10867
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12334139 times.
13318826 else if(dmisc9==e9tROPE) //Rope charge
10868 {
10869
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10870 {
10871
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10872 {
10873
10874
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10875 {
10876 14 hp=-1000;
10877
10878
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10879 {
10880
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10881 14 Ewpns.add(ew);
10882 14 ew->fakez = fakez;
10883
10884
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10885 {
10886 14 ew->step=0;
10887 14 ew->id=wpn+dmisc3;
10888 14 ew->misc=50;
10889 14 ew->clk=48;
10890 14 }
10891
10892 14 fired=true;
10893 14 }
10894 else
10895 {
10896 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10897 Ewpns.add(ew);
10898 ew->fakez = fakez;
10899
10900 if(wpn==ewSBomb || wpn==ewBomb)
10901 {
10902 ew->step=0;
10903 ew->id=wpn;
10904 ew->misc=50;
10905 ew->clk=48;
10906 }
10907
10908 fired=true;
10909 }
10910 14 }
10911
10912 else
10913 {
10914 33 hp=-1000;
10915
10916 int32_t wpn2;
10917
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10918 33 wpn2=wpn;
10919 else
10920 wpn2=wpn;
10921
10922
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10923 33 Ewpns.add(ew);
10924 33 ew->fakez = fakez;
10925
10926
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10927 {
10928 33 ew->step=0;
10929 33 ew->id=wpn2;
10930 33 ew->misc=50;
10931 33 ew->clk=48;
10932 33 }
10933
10934 33 fired=true;
10935 }
10936 47 }
10937 125869 }
10938
10939 984687 charge_attack();
10940 984687 break;
10941 }
10942 /*
10943 * Boomerang-throwers have a halt count of 1
10944 * Zols have a halt count of (zc_oldrand()&7)<<4
10945 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10946 * Everything else has 48
10947 */
10948 else
10949 {
10950
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11765720 times.
12334139 if(wpn==ewBrang) // Goriya
10951 {
10952 568419 halting_walk(rate,homing,0,hrate, 1);
10953 568419 }
10954
4/4
✓ Branch 0 taken 11616344 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4552225 times.
✓ Branch 3 taken 7064119 times.
11765720 else if(dmisc9==e9tNORMAL && wpn==0)
10955 {
10956
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6346146 times.
7064119 if(dmisc2==e2tSPLITHIT) // Zol
10957 {
10958 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10959 717973 }
10960
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4591991 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6346146 else if(frate<=8 && starting_hp==1) // Gel
10961 {
10962 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10963 215891 }
10964 else // Other
10965 {
10966 6130255 halting_walk(rate,homing,0,hrate, 48);
10967 }
10968 7064119 }
10969 else // Other
10970 {
10971 4701601 halting_walk(rate,homing,0,hrate, 48);
10972 }
10973 }
10974
10975 //if not in midair, and Hero's swinging sword is nearby, jump.
10976 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10977 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10978 {
10979 facehero(false);
10980 sclk=16+((dir^1)<<8);
10981 fall=-FEATHERJUMP;
10982 sfx(WAV_ZN1JUMP,pan(x));
10983 }*/
10984 12334139 break;
10985
10986 // Following cases are for just after creation-by-splitting.
10987 case 1:
10988
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10989 {
10990 821 dir=up;
10991 821 step=8;
10992 821 }
10993
10994
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10995 {
10996 2504 move(step);
10997
10998
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10999 512 dir=down;
11000 2504 }
11001
11002
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11003 {
11004
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11005 503 x+=16;
11006 790 }
11007
11008 3294 ++misc;
11009 3294 break;
11010
11011 case 2:
11012
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11013 {
11014 15 dir=down;
11015 15 step=8;
11016 15 }
11017
11018
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11019 {
11020 45 move(step);
11021 /*
11022 if(!canmove(dir,(zfix)0,0,false))
11023 dir=up;
11024 */
11025 45 }
11026
11027
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11028 {
11029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11030 14 x-=16;
11031 14 }
11032
11033 59 ++misc;
11034 59 break;
11035
11036 default:
11037
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11038 {
11039 28 dir=(zc_oldrand()%4);
11040 28 step=8;
11041 28 }
11042
11043
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11044 {
11045 83 move(step);
11046
11047
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11048 2 dir=dir^1;
11049 83 }
11050
11051
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11052 {
11053
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11054 8 x+=(dir==left ? -16 : 16);
11055 25 }
11056
11057 108 ++misc;
11058 108 break;
11059 14118397 }
11060
11061
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14932595 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14957867 if(id>>12 && misc>=4) //recently spawned by a split enemy
11062 {
11063 829 id&=0xFFF;
11064 829 step = zslongToFix(dstep*100);
11065
11066
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11067
11068
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11069
11070
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11071
11072
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11073
11074 829 misc=3;
11075 829 }
11076 14957867 }
11077 else
11078 {
11079 //sfx(wpnsfx(wpn),pan(x));
11080
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11081 }
11082
11083 // Fire Zol
11084
8/8
✓ Branch 0 taken 6104972 times.
✓ Branch 1 taken 9292938 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965691 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15397910 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11085 {
11086 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11087 1102 sfx(wpnsfx(wpn),pan(x));
11088
11089 1102 int32_t i=Ewpns.Count()-1;
11090 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11091
11092
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11093 {
11094 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11095 if ( ew->do_animation ) ew->tile+=ew->aframe;
11096 }
11097 1102 }
11098 // Goriya
11099
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14347935 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15396808 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11100 {
11101 6362 misc=index+100;
11102
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11103 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11104
11105
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11106 {
11107 257 int32_t ndir=dir;
11108
11109
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11110 {
11111 6 ndir=(Hero.y+8<y)?up:down;
11112 6 }
11113 else //turn to face Hero
11114 {
11115 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11116 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11117
11118
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11119 {
11120 13 ndir=down;
11121 13 }
11122
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11123 {
11124 68 ndir=right;
11125 68 }
11126
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11127 {
11128 48 ndir=up;
11129 48 }
11130 else
11131 {
11132 122 ndir=left;
11133 }
11134 }
11135
11136 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11137
11138
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11139 {
11140 223 dir=ndir;
11141 223 }
11142 257 }
11143 6362 }
11144
15/16
✓ Branch 0 taken 15331557 times.
✓ Branch 1 taken 58889 times.
✓ Branch 2 taken 221201 times.
✓ Branch 3 taken 15169245 times.
✓ Branch 4 taken 195083 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170191 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168807 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153707 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153707 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152763 times.
15390446 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11145
3/3
✓ Branch 0 taken 26125 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152763 switch(dmisc1)
11146 {
11147 case e1tCONSTANT: //Deathnut
11148 {
11149 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11150
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11151 {
11152 2583 clk5=0;
11153 2583 fired=false;
11154 2583 }
11155
11156 125732 clk5+=(zc_oldrand()&3);
11157
11158
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11159 {
11160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11161
11162
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11163 {
11164
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11165 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11166 2827 sfx(wpnsfx(wpn),pan(x));
11167 2827 fired=true;
11168 2827 }
11169 51069 }
11170
11171 125732 break;
11172 }
11173
11174 case e1tFIREOCTO: //Fire Octo
11175 906 timer=zc_oldrand()%50+50;
11176 906 break;
11177
11178 default:
11179 26125 FireWeapon();
11180 26125 break;
11181 152763 }
11182
11183 /* Fire again if:
11184 * - clk2 about to run out
11185 * - not already double-firing (dmisc1 is 1)
11186 * - not carrying Hero
11187 * - one in 0xF chance
11188 */
11189
8/10
✓ Branch 0 taken 524941 times.
✓ Branch 1 taken 14872969 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520939 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15397910 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11190 {
11191 #if 1
11192 251 newdir(rate, homing, grumble);
11193 #else
11194 dir^=2;
11195 #endif
11196 251 clk2=28;
11197 251 ++multishot;
11198 251 }
11199
11200
2/2
✓ Branch 0 taken 3492813 times.
✓ Branch 1 taken 11905097 times.
15397910 if(clk2==0)
11201 {
11202 11905097 multishot = 0;
11203 11905097 }
11204
11205
2/2
✓ Branch 0 taken 15333600 times.
✓ Branch 1 taken 64310 times.
15397910 if(timer) //Fire Octo
11206 {
11207 64310 clk2=15; //this keeps the octo in place until he's done firing
11208
11209
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11210 {
11211 15752 FireBreath(false);
11212 15752 }
11213
11214 64310 --timer;
11215 64310 }
11216
11217
2/2
✓ Branch 0 taken 15148517 times.
✓ Branch 1 taken 249393 times.
15397910 if(dmisc2==e2tTRIBBLE)
11218 249393 ++clk4;
11219
11220
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15393430 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15397217 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15397910 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11221 {
11222 693 int32_t kids = guys.Count();
11223 693 int32_t id2=dmisc3;
11224
11225
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11226 {
11227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11228 {
11229
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11230 {
11231 int guycarryingitem = guys.Count()-1;
11232 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11233 itemguy = false;
11234 }
11235
11236 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11237 693 }
11238 693 }
11239
11240
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11241 {
11242 Hero.setEaten(0);
11243 hashero=false;
11244 }
11245
11246 693 stop_bgsfx(index);
11247 693 return true;
11248 }
11249
11250 15397217 return enemy::animate(index);
11251 15823224 }
11252
11253 16245517 void eStalfos::draw(BITMAP *dest)
11254 {
11255 16245517 update_enemy_frame();
11256
11257
7/8
✓ Branch 0 taken 16245091 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16245091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16158140 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16245517 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11258 {
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11260 11115 }
11261
11262 16245517 enemy::draw(dest);
11263 16245517 }
11264
11265 7536565 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11266 {
11267 7536565 int32_t tempy=yofs;
11268
11269
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224946 times.
✓ Branch 3 taken 311619 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11270 {
11271 311619 flip = 0;
11272 311619 int32_t fdiv = frate/4;
11273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11274
11275
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11276 311619 efrate:((clk>=(frate>>1))?1:0);
11277 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11278
11279
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11280 {
11281 311619 shadowtile+=f2;
11282 311619 }
11283 else
11284 {
11285 shadowtile+=f2?1:0;
11286 }
11287
11288 311619 yofs+=shadowdistance;
11289 311619 yofs+=8;
11290 311619 }
11291
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533530 times.
✓ Branch 3 taken 3035 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11292 {
11293 3035 flip = 0;
11294 3035 int32_t fdiv = frate/4;
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11296
11297
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11298 3035 efrate:((clk>=(frate>>1))?1:0);
11299 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11300
11301
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11302 {
11303 3035 shadowtile+=f2;
11304 3035 }
11305 else
11306 {
11307 shadowtile+=f2?1:0;
11308 }
11309 3035 }
11310
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7531069 times.
7536565 if(!shadow_overpit(this))
11311 7531069 enemy::drawshadow(dest, translucent);
11312 7536565 yofs=tempy;
11313 7536565 }
11314
11315 157815 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11316 {
11317 157815 int32_t wpnId = w->id;
11318 157815 int32_t wpnDir = w->dir;
11319
11320
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156397 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157815 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11321
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11322
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11323 {
11324 265 shield = false;
11325 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11326
11327
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11328 243 o_tile=s_tile;
11329 265 }
11330
11331 157815 int32_t ret = enemy::takehit(w,realweap);
11332
11333
4/4
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 135488 times.
✓ Branch 2 taken 20576 times.
✓ Branch 3 taken 1751 times.
157815 if(sclk && dmisc2==e2tSPLITHIT)
11334 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11335
11336 157815 return ret;
11337 }
11338
11339 984687 void eStalfos::charge_attack()
11340 {
11341
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11342 6715 return;
11343
11344
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11345 59093 return;
11346
11347
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11348 {
11349 37515 fix_coords(true);
11350
11351
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11352 {
11353 27472 int32_t ldir = lined_up(7,false);
11354
11355
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11356 {
11357 2651 dir=ldir;
11358 2651 dashing=true;
11359
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11360 2651 step=zslongToFix(dstep*100)+1;
11361 else
11362 step=zslongToFix(dmisc10*100);
11363 2651 }
11364 24821 else newdir(4,0,0);
11365 27472 }
11366
11367
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11368 {
11369 1454 step=zslongToFix(dstep*100);
11370 1454 newdir();
11371 1454 dashing=false;
11372 1454 }
11373
11374 37515 zfix div = step;
11375
11376
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11377 div = 1;
11378
11379 37515 clk3=(int32_t)(16.0/div);
11380 37515 return;
11381 }
11382
11383 881364 move(step);
11384 881364 --clk3;
11385 984687 }
11386
11387 796110 void eStalfos::vire_hop()
11388 {
11389
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11390 {
11391
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11392 {
11393
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11394 3843 }
11395 376292 }
11396 417076 else sclk=0;
11397
11398
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11399 31892 return;
11400
11401 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11402 int32_t jump_height;
11403
11404
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11405 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11406 else jump_height = dmisc10;
11407
11408 761476 y=floor_y;
11409
11410
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11411 {
11412 26258 fix_coords();
11413
11414 //z=0;
11415 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11416 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11417
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11418 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11419
11420
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11421 {
11422 //z=0;
11423
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11424 {
11425
11426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11427 17258 }
11428 21336 }
11429
11430
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11431 {
11432 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11433 7030 }
11434
11435 26258 clk3=int32_t(16.0/step.getFloat());
11436 26258 }
11437
11438 761476 --clk3;
11439
11440
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11441 761476 move(step);
11442
11443 761476 floor_y=y;
11444 761476 clk2--;
11445
11446 //if we're in the middle of a jump
11447
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11448 {
11449 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11450
11451
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11452 {
11453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11454 93147 else z=h;
11455 93147 }
11456 else
11457 {
11458 384731 y=floor_y-h;
11459 384731 shadowdistance=h;
11460 }
11461 477878 }
11462 else
11463 283598 shadowdistance = 0;
11464 796110 }
11465
11466 138 void eStalfos::eathero()
11467 {
11468
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11469 {
11470 70 hashero=true;
11471 70 y=floor_y;
11472 70 z=0;
11473
11474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11475 {
11476 Hero.setX(x);
11477 Hero.setY(y);
11478 }
11479 else
11480 {
11481 70 x=Hero.getX();
11482 70 y=Hero.getY();
11483 }
11484
11485 70 clk2=0;
11486 70 }
11487 138 }
11488
11489 1469390 bool eStalfos::WeaponOut()
11490 {
11491
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11492 {
11493
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11494 {
11495 846991 return true;
11496 }
11497 1553588 }
11498
11499 622399 return false;
11500 1469390 }
11501
11502 353022 void eStalfos::KillWeapon()
11503 {
11504
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 353022 times.
646406 for(int32_t i=0; i<Ewpns.Count(); i++)
11505 {
11506
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11507 {
11508 //only kill this Goriya's boomerang -DD
11509
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11510 {
11511 411 Ewpns.del(i);
11512 411 }
11513 810 }
11514 293384 }
11515 353022 }
11516
11517 void eStalfos::break_shield()
11518 {
11519 if(!shield)
11520 return;
11521
11522 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11523 shield=false;
11524
11525 if(get_qr(qr_BRKNSHLDTILES))
11526 o_tile=s_tile;
11527 }
11528
11529 void eStalfos::repair_shield()
11530 {
11531 if (shield)
11532 return;
11533
11534 shield = true;
11535
11536 if (get_qr(qr_BRKNSHLDTILES))
11537 {
11538 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11539 else o_tile = d->tile;
11540 }
11541 }
11542
11543 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11544 13720 {
11545
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11546
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11547 13720 movestatus=1;
11548
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11549 {
11550 step = dmisc19/100.0;
11551 movestatus = 1;
11552 }
11553
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11554 13720 c=0;
11555 13720 clk4=0;
11556 //nets;
11557
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11558 13720 dummy_int[1]=0;
11559 13720 }
11560
11561 3535341 bool eKeese::animate(int32_t index)
11562 {
11563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11564
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11565
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11566 124509 return Dead(index);
11567
11568
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11569 {
11570 26191 removearmos(x,y,ffcactivated);
11571 26191 }
11572
11573
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11574 {
11575 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11576 1025042 }
11577 else
11578 {
11579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11580 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11581 }
11582
11583
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11584 {
11585
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11586 {
11587
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11588 {
11589 105 int32_t kids = guys.Count();
11590 105 bool success = false;
11591 105 int32_t id2=dmisc3;
11592 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11593
11594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11595 {
11596
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11597 {
11598 int guycarryingitem = guys.Count()-1;
11599 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11600 itemguy = false;
11601 }
11602
11603 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11604 105 }
11605
11606 105 stop_bgsfx(index);
11607 105 return true;
11608 }
11609 else
11610 {
11611 86 clk4=0;
11612 }
11613 86 }
11614 120233 }
11615 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11616
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11617 {
11618
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11619 {
11620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11621 {
11622 fakez=int32_t(step/zslongToFix(dstep*100));
11623 // Some variance in keese flight heights when away from Hero
11624 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11625
11626 }
11627 else
11628 {
11629 687068 z=int32_t(step/zslongToFix(dstep*100));
11630 // Some variance in keese flight heights when away from Hero
11631
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11632 }
11633 687068 }
11634 else
11635 {
11636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11637 {
11638 fakez=int32_t(step/zslongToFix(dstep*100));
11639 // Some variance in keese flight heights when away from Hero
11640 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11641
11642 }
11643 else
11644 {
11645 158811 z=int32_t(step/zslongToFix(dstep*100));
11646 // Some variance in keese flight heights when away from Hero
11647
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11648 }
11649 }
11650 845879 }
11651
11652 3410727 return enemy::animate(index);
11653 3535341 }
11654
11655 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11656 {
11657 2088281 int32_t tempy=yofs;
11658 2088281 flip = 0;
11659 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11660
11661
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11662
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11663 {
11664 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11665 1397718 }
11666
11667
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11668 2052223 enemy::drawshadow(dest, translucent);
11669 2088281 yofs=tempy;
11670 2088281 }
11671
11672 7949863 void eKeese::draw(BITMAP *dest)
11673 {
11674 7949863 update_enemy_frame();
11675 7949863 enemy::draw(dest);
11676 7949863 }
11677
11678 13720 void eKeese::init_size_flags()
11679 {
11680 13720 SIZEflags = d->SIZEflags;
11681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11682
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11683
11684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11686
11687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11688
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11689
11690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11692
11693
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11694 // al_trace("Enemy txsz:%i\n", txsz);
11695
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11696
11697
11698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11699
11700
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11701
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11702 {
11703 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11704 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11705 }
11706
11707
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11708 13720 }
11709
11710 20171 void eWizzrobe::submerge(bool set)
11711 {
11712
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11713 {
11714 20024 hxofs = set?1000:0;
11715 20024 return;
11716 }
11717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11718 147 submerged = set;
11719
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11720 76 hxofs+=1000;
11721 71 else hxofs -= 1000;
11722 20171 }
11723 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11724 5350 {
11725 5350 hxofs = 0;
11726 5350 submerged = false;
11727
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11728 {
11729 case 0:
11730 2992 submerge(true);
11731 2992 fading=fade_invisible;
11732 // Set clk to just before the 'reappear' threshold
11733
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11734 2992 break;
11735
11736 default:
11737 2358 dir=(loadside==right)?right:left;
11738 2358 misc=-3;
11739 2358 break;
11740 }
11741
11742 //netst+2880;
11743 5350 charging=false;
11744 5350 firing=false;
11745 5350 fclk=0;
11746
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11747
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11748 5350 }
11749
11750 2081613 bool eWizzrobe::animate(int32_t index)
11751 {
11752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11753
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11754
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11755 {
11756 38023 return Dead(index);
11757 }
11758
11759
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11760 {
11761 66646 removearmos(x,y,ffcactivated);
11762 66646 }
11763
11764
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11765 {
11766 1019220 wizzrobe_attack();
11767 1019220 }
11768 else // Teleporting
11769 {
11770
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11771 {
11772 7084 fading=0;
11773 7084 submerge(false);
11774 7084 solid_update(false);
11775 7084 }
11776
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11777 {
11778 case 0:
11779
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11780 {
11781 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11782 // but should not appear on dungeon walls.
11783
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11784
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11785 {
11786 //2.10 Windrobe
11787 //randomise location and face Hero
11788 224 int32_t t=0;
11789 224 bool placed=false;
11790
11791
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11792 {
11793
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11794 {
11795 280 x=((zc_oldrand()%12)+2)*16;
11796 280 y=((zc_oldrand()%7)+2)*16;
11797 280 }
11798 else
11799 {
11800 87 x=((zc_oldrand()%14)+1)*16;
11801 87 y=((zc_oldrand()%9)+1)*16;
11802 }
11803
11804 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11805
11806
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11807 {
11808 224 placed=true;
11809 224 }
11810
11811 367 ++t;
11812 }
11813
11814
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11815 {
11816
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11817 {
11818 47 dir=down;
11819 47 }
11820 else
11821 {
11822 14 dir=up;
11823 }
11824 61 }
11825 else
11826 {
11827
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11828 {
11829 72 dir=right;
11830 72 }
11831 else
11832 {
11833 91 dir=left;
11834 }
11835 }
11836
11837
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11838 return true;
11839
11840
11841 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11842 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11843 224 }
11844 4486 else place_on_axis(true, dmisc4!=0);
11845 5123 }
11846 else
11847 {
11848 1117 int32_t t=0;
11849 1117 bool placed=false;
11850
11851
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11852 {
11853
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11854 {
11855 1340 x=((zc_oldrand()%12)+2)*16;
11856 1340 y=((zc_oldrand()%7)+2)*16;
11857 1340 }
11858 else
11859 {
11860 1103 x=((zc_oldrand()%14)+1)*16;
11861 1103 y=((zc_oldrand()%9)+1)*16;
11862 }
11863
11864 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11865
11866
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11867 {
11868 1117 placed=true;
11869 1117 }
11870
11871 2443 ++t;
11872 }
11873
11874
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11875 {
11876
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11877 {
11878 238 dir=down;
11879 238 }
11880 else
11881 {
11882 148 dir=up;
11883 }
11884 386 }
11885 else
11886 {
11887
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11888 {
11889 340 dir=right;
11890 340 }
11891 else
11892 {
11893 391 dir=left;
11894 }
11895 }
11896
11897
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11898 return true;
11899 }
11900
11901 6240 fading=fade_flicker;
11902 6240 submerge(false);
11903 6240 solid_update(false);
11904 6240 break;
11905
11906 case 64:
11907 5313 fading=0;
11908 5313 charging=true;
11909 5313 break;
11910
11911 case 73:
11912 5151 charging=false;
11913 5151 firing=40;
11914 5151 break;
11915
11916 case 83:
11917 5006 wizzrobe_attack_for_real();
11918 5006 break;
11919
11920 case 119:
11921 4247 firing=false;
11922 4247 charging=true;
11923 4247 break;
11924
11925 case 128:
11926 4109 fading=fade_flicker;
11927 4109 charging=false;
11928 4109 break;
11929
11930 case 146:
11931 3855 fading=fade_invisible;
11932 3855 submerge(true);
11933 3855 solid_update(false);
11934
11935 [[fallthrough]];
11936 default:
11937
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11938 6249 clk=-1;
11939
11940 987220 break;
11941 }
11942 }
11943
11944 2043590 return enemy::animate(index);
11945 2081613 }
11946
11947 7929 void eWizzrobe::wizzrobe_attack_for_real()
11948 {
11949
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11950 return;
11951
11952
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11953 {
11954 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11955 5946 sfx(firesfx, pan(x));
11956 5946 }
11957
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11958 {
11959 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11960 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11961 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11962 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11963 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11964 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11965 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11966 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11967 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11968 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11969 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11970 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11971 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11972 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11973 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11974 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11975 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11976 //i've compromised by making all old quest use this code chunk by default.
11977
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11978 {
11979 995 sfx(WAV_FIRE, pan(x));
11980
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11981 else
11982 {
11983
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11984 {
11985 19 case ewFireball: sfx(40, pan(x)); break;
11986 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11987 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11988 case ewRock: sfx(51, pan(x)); break;
11989 68 case ewMagic: sfx(32, pan(x)); break;
11990 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11991 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11992 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11993 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11994 case ewFireTrail: sfx(13, pan(x)); break;
11995 420 case ewFlame: sfx(13, pan(x)); break;
11996 case ewWind: sfx(32, pan(x)); break;
11997 case ewFlame2: sfx(13, pan(x)); break;
11998 case ewFlame2Trail: sfx(13, pan(x)); break;
11999 case ewIce: sfx(44, pan(x)); break;
12000 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
12001 default: sfx(WAV_FIRE, pan(x)); break;
12002 }
12003 }
12004 995 }
12005 else
12006 {
12007 sfx(firesfx, pan(x));
12008 }
12009 995 }
12010
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12011 {
12012 971 int32_t bc=0;
12013
12014
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12015 {
12016
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12017 {
12018 5195 ++bc;
12019 5195 }
12020 10497 }
12021
12022
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12023 {
12024 963 int32_t kids = guys.Count();
12025 963 int32_t bats=(zc_oldrand()%3)+1;
12026
12027
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12028 {
12029 // Summon bats (or anything)
12030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12031 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12032 1965 }
12033 963 sfx(firesfx, pan(x));
12034 963 }
12035 971 }
12036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12037 {
12038
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12039 {
12040 return;
12041 }
12042
12043 17 int32_t kids = guys.Count();
12044
12045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12046 {
12047 17 int32_t newguys=(zc_oldrand()%3)+1;
12048 17 bool summoned=false;
12049
12050
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12051 {
12052 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12053 32 int32_t x2=0;
12054 32 int32_t y2=0;
12055
12056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12057 {
12058 36 x2=16*((zc_oldrand()%12)+2);
12059 36 y2=16*((zc_oldrand()%7)+2);
12060
12061
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12062 {
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12064 {
12065 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12066
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12067 {
12068 ((enemy*)guys.spr(kids+i))->fakez = 64;
12069 ((enemy*)guys.spr(kids+i))->z = 0;
12070 }
12071 32 }
12072
12073 32 summoned=true;
12074 32 break;
12075 }
12076 4 }
12077 32 }
12078
12079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12080 {
12081 17 sfx(firesfx, pan(x));
12082 17 }
12083 17 }
12084 17 }
12085 7929 }
12086
12087
12088 1019220 void eWizzrobe::wizzrobe_attack()
12089 {
12090
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12091 86341 return;
12092
12093
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12094 {
12095 39538 fix_coords();
12096
12097
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12098 {
12099 case 1: //walking
12100
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12101 2644 misc=0;
12102 else
12103 {
12104 10364 clk3=16;
12105
12106
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12107 {
12108 1398 wizzrobe_newdir(0);
12109 1398 }
12110 }
12111
12112 13008 break;
12113
12114 case 2: //phasing
12115 {
12116 3903 int32_t jx=x;
12117 3903 int32_t jy=y;
12118 3903 int32_t jdir=-1;
12119
12120
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12121 {
12122 case 0:
12123 484 jx-=32;
12124 484 jy-=32;
12125 484 jdir=15;
12126 484 break;
12127
12128 case 1:
12129 472 jx+=32;
12130 472 jy-=32;
12131 472 jdir=9;
12132 472 break;
12133
12134 case 2:
12135 482 jx+=32;
12136 482 jy+=32;
12137 482 jdir=11;
12138 482 break;
12139
12140 case 3:
12141 492 jx-=32;
12142 492 jy+=32;
12143 492 jdir=13;
12144 492 break;
12145 }
12146
12147
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12148 {
12149 1140 misc=3;
12150 1140 clk3=32;
12151 1140 dir=jdir;
12152 1140 break;
12153 }
12154 2763 }
12155 [[fallthrough]];
12156 case 3:
12157 3813 dir&=3;
12158 3813 misc=0;
12159 [[fallthrough]];
12160 case 0:
12161 19894 wizzrobe_newdir(64);
12162 [[fallthrough]];
12163 default:
12164
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12165 {
12166
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12167 {
12168 3265 misc=1;
12169 3265 clk3=16;
12170 3265 }
12171 else
12172 {
12173 239 wizzrobe_newdir(64);
12174 239 misc=0;
12175 239 clk3=32;
12176 }
12177 3504 }
12178 else
12179 {
12180 21886 clk3=32;
12181 }
12182
12183 25390 break;
12184 }
12185
12186
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12187 4478 ++misc;
12188 39538 }
12189
12190 932879 --clk3;
12191
12192
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12193 {
12194 case 1:
12195 case 3:
12196 248377 step=1;
12197 248377 break;
12198
12199 case 2:
12200 63903 step=0;
12201 63903 break;
12202
12203 default:
12204 620599 step=0.5;
12205 620599 break;
12206
12207 }
12208
12209 932879 move(step);
12210
12211 // if(d->misc1 && misc<=0 && clk3==28)
12212
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12213 {
12214
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12215 {
12216
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12217 {
12218 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12219 // sfx(WAV_WAND,pan(x));
12220 1928 wizzrobe_attack_for_real();
12221 1928 fclk=30;
12222 1928 }
12223 16835 }
12224 else
12225 {
12226
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12227 {
12228 995 wizzrobe_attack_for_real();
12229 995 fclk=30;
12230 995 }
12231 }
12232 21547 }
12233
12234
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12235 4050 misc=2;
12236
12237
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12238 3441 fix_coords();
12239
12240
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12241 {
12242
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12243 {
12244 83282 --fclk;
12245 83282 }
12246 932879 }
12247
12248 1019220 }
12249
12250 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12251 {
12252 // Wizzrobes shouldn't move to the edge of the screen;
12253 // if they're already there, they should move toward the center
12254
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12255 33 dir=right;
12256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12257 4 dir=left;
12258
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12259 2 dir=down;
12260
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12261 5 dir=up;
12262 else
12263 21487 newdir(4,homing,spw_wizzrobe);
12264 21531 }
12265
12266 2099229 void eWizzrobe::draw(BITMAP *dest)
12267 {
12268 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12269
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12270 125018 return;
12271
12272 1974211 int32_t tempint=dummy_int[1];
12273 1974211 bool tempbool1=dummy_bool[1];
12274 1974211 bool tempbool2=dummy_bool[2];
12275 1974211 dummy_int[1]=fclk;
12276 1974211 dummy_bool[1]=charging;
12277 1974211 dummy_bool[2]=firing;
12278 1974211 update_enemy_frame();
12279 1974211 dummy_int[1]=tempint;
12280 1974211 dummy_bool[1]=tempbool1;
12281 1974211 dummy_bool[2]=tempbool2;
12282 1974211 enemy::draw(dest);
12283 2099229 }
12284
12285 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12286 203 {
12287 203 fading=fade_flash_die;
12288
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12289 {
12290 3 dir=up;
12291 3 }
12292
12293
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12294 {
12295 dir=left;
12296 }
12297
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12298 203 }
12299
12300 125855 bool eDodongo::animate(int32_t index)
12301 {
12302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12303
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12304 {
12305 3790 return Dead(index);
12306 }
12307
12308
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12309 {
12310 569 removearmos(x,y,ffcactivated);
12311 569 }
12312
12313
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12314 {
12315
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12316 113 hp-=misc; // store bomb's power in misc
12317 10848 }
12318 else
12319 111217 constant_walk(rate,homing,spw_clipright);
12320
12321 122065 hit_width = (dir<=down) ? 16 : 32;
12322 // hysz = (dir>=left) ? 16 : 32;
12323
12324 122065 return enemy::animate(index);
12325 125855 }
12326
12327 125845 void eDodongo::draw(BITMAP *dest)
12328 {
12329 125845 tile=o_tile;
12330
12331
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12332 {
12333 3065 enemy::drawzcboss(dest);
12334 3065 return;
12335 }
12336
12337 122780 update_enemy_frame();
12338 122780 enemy::drawzcboss(dest);
12339
12340
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12341 {
12342 71118 tile+=dummy_int[1]; //second tile is previous tile
12343 71118 xofs-=16; //new xofs change
12344 71118 enemy::drawzcboss(dest);
12345 71118 xofs+=16;
12346 71118 }
12347
12348 125845 }
12349
12350 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12351 {
12352 8218 int32_t wpnId = w->id;
12353 8218 int32_t power = w->power;
12354 8218 int32_t wpnx = w->x;
12355 8218 int32_t wpny = w->y;
12356
12357
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12358 5761 return 0;
12359
12360
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12361 {
12362 case wPhantom:
12363 return 0;
12364
12365 case wFire:
12366 case wBait:
12367 case wWhistle:
12368 case wWind:
12369 case wSSparkle:
12370 case wFSparkle:
12371 return 0;
12372
12373 case wLitBomb:
12374 case wLitSBomb:
12375
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12376 690 return 0;
12377
12378 113 clk2=96;
12379 113 misc=power;
12380
12381
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12382 3 item_set=isSBOMB100;
12383
12384 113 return 1;
12385
12386 case wBomb:
12387 case wSBomb:
12388
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12389 516 return 0;
12390
12391 975 stunclk=160;
12392 975 misc=wpnId; // store wpnId
12393 975 return 1;
12394
12395 case wSword:
12396
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12397 {
12398 88 sfx(WAV_EHIT,pan(x));
12399 88 hp=0;
12400 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12401 88 fading=0; // don't flash
12402 88 return 1;
12403 }
12404
12405 [[fallthrough]];
12406 default:
12407 75 sfx(WAV_CHINK,pan(x));
12408 75 }
12409
12410 75 return 1;
12411 8218 }
12412
12413 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12414 48 {
12415 48 fading=fade_flash_die;
12416 //nets+5180;
12417 48 previous_dir=-1;
12418
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12419 {
12420 1 dir=up;
12421 1 }
12422
12423
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12424 {
12425 dir=left;
12426 }
12427
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12428 48 }
12429
12430 39398 bool eDodongo2::animate(int32_t index)
12431 {
12432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12433
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12434 {
12435 1158 return Dead(index);
12436 }
12437
12438
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12439 {
12440 167 removearmos(x,y,ffcactivated);
12441 167 }
12442
12443
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12444 {
12445
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12446 42 hp-=misc; // store bomb's power in misc
12447 4032 }
12448 else
12449 34208 constant_walk(rate,homing,spw_clipbottomright);
12450
12451 38240 hit_width = (dir<=down) ? 16 : 32;
12452 38240 hit_height = (dir>=left) ? 16 : 32;
12453 38240 hxofs=(dir>=left)?-8:0;
12454 38240 hyofs=(dir<left)?-8:0;
12455
12456 38240 return enemy::animate(index);
12457 39398 }
12458
12459 39601 void eDodongo2::draw(BITMAP *dest)
12460 {
12461
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12462 {
12463 768 enemy::drawzcboss(dest);
12464 768 return;
12465 }
12466
12467 38833 int32_t tempx=xofs;
12468 38833 int32_t tempy=yofs;
12469 38833 update_enemy_frame();
12470 38833 enemy::drawzcboss(dest);
12471 38833 tile+=dummy_int[1]; //second tile change
12472 38833 xofs+=dummy_int[2]; //new xofs change
12473 38833 yofs+=dummy_int[3]; //new yofs change
12474 38833 enemy::drawzcboss(dest);
12475 38833 xofs=tempx;
12476 38833 yofs=tempy;
12477 39601 }
12478
12479 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12480 {
12481 3929 int32_t wpnId = w->id;
12482 3929 int32_t power = w->power;
12483 3929 int32_t wpnx = w->x;
12484 3929 int32_t wpny = w->y;
12485
12486
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12487 2377 return 0;
12488
12489
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12490 {
12491 case wPhantom:
12492 return 0;
12493
12494 case wFire:
12495 case wBait:
12496 case wWhistle:
12497 case wWind:
12498 case wSSparkle:
12499 case wFSparkle:
12500 346 return 0;
12501
12502 case wLitBomb:
12503 case wLitSBomb:
12504
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12505 {
12506 case up:
12507
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12508 77 return 0;
12509
12510 4 break;
12511
12512 case down:
12513
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12514 71 return 0;
12515
12516 6 break;
12517
12518 case left:
12519
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12520 66 return 0;
12521
12522 16 break;
12523
12524 case right:
12525
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12526 65 return 0;
12527
12528 16 break;
12529 }
12530
12531 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12532 // return 0;
12533 42 clk2=96;
12534 42 misc=power;
12535
12536
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12537 item_set=isSBOMB100;
12538
12539 42 return 1;
12540
12541 case wBomb:
12542 case wSBomb:
12543
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12544 {
12545 case up:
12546
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12547 84 return 0;
12548
12549 92 break;
12550
12551 case down:
12552
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12553 113 return 0;
12554
12555 55 break;
12556
12557 case left:
12558
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12559 80 return 0;
12560
12561 105 break;
12562
12563 case right:
12564
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12565 71 return 0;
12566
12567 93 break;
12568 }
12569
12570 345 stunclk=160;
12571 345 misc=wpnId; // store wpnId
12572 345 return 1;
12573
12574 case wSword:
12575
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12576 {
12577 34 sfx(WAV_EHIT,pan(x));
12578 34 hp=0;
12579 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12580 34 fading=0; // don't flash
12581 34 return 1;
12582 }
12583
12584 [[fallthrough]];
12585 default:
12586 158 sfx(WAV_CHINK,pan(x));
12587 158 }
12588
12589 158 return 1;
12590 3929 }
12591
12592 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12593 126 {
12594 //these are here to bypass compiler warnings about unused arguments
12595
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12596 {
12597
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12598 126 }
12599 else { x = X; y = Y; }
12600
12601 //nets+5940;
12602
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12603 {
12604 81 }
12605 else
12606 {
12607
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12608 {
12609 7 flip=1;
12610 7 }
12611 }
12612
12613
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12614 126 clk3=32;
12615 126 clk2=0;
12616 126 clk4=clk;
12617 126 dir=left;
12618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12619 126 }
12620
12621 71899 bool eAquamentus::animate(int32_t index)
12622 {
12623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12624
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12625 2092 return Dead(index);
12626
12627 // fbx=x+((id==eRAQUAM)?4:-4);
12628
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12629 {
12630 317 removearmos(x,y,ffcactivated);
12631 317 }
12632
12633 69807 fbx=x;
12634
12635 /*
12636 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12637 {
12638 fbx+=16;
12639 }
12640 */
12641
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12642 {
12643 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12644 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12645 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12646 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12647 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12648 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12649 450 sfx(wpnsfx(wpn),pan(x));
12650 450 }
12651
12652
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12653 {
12654 345 clk3=32;
12655 345 }
12656
12657 69807 int screen_x = x.getInt()%256;
12658
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12659 {
12660 1117 int32_t d2=(zc_oldrand()%3)+1;
12661
12662
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12663 {
12664 752 dir=d2;
12665 752 }
12666
12667
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12668 {
12669
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12670 {
12671 38 dir=right;
12672 38 }
12673
12674
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12675 {
12676 dir=left;
12677 }
12678 385 }
12679 else
12680 {
12681
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12682 {
12683 21 dir=right;
12684 21 }
12685
12686
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12687 {
12688 34 dir=left;
12689 34 }
12690 }
12691 1117 }
12692
12693
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12694 {
12695
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12696 {
12697 4546 x-=1;
12698 4546 }
12699 else
12700 {
12701 3995 x+=1;
12702 }
12703 8541 }
12704
12705 69807 clk4=(clk4+1)%256;
12706
12707 69807 return enemy::animate(index);
12708 71899 }
12709
12710 72310 void eAquamentus::draw(BITMAP *dest)
12711 {
12712
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12713 {
12714 44994 xofs=(dmisc1?-16:0);
12715
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12716
12717
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12718 {
12719 1312 xofs=0;
12720 1312 enemy::draw(dest);
12721 1312 }
12722 else
12723 {
12724 43682 drawblock(dest,15);
12725 }
12726 44994 }
12727 else
12728 {
12729 27316 int32_t xblockofs=((dmisc1)?-16:16);
12730 27316 xofs=0;
12731
12732
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12733 {
12734 1462 enemy::draw(dest);
12735 1462 return;
12736 }
12737
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12738 {
12739 // face (0=firing, 2=resting)
12740 25854 tile=o_tile+((clk3>0)?0:2);
12741 25854 enemy::draw(dest);
12742 // tail (
12743 25854 tile=o_tile+((clk&16)?1:3);
12744 25854 xofs=xblockofs;
12745 25854 enemy::draw(dest);
12746 // body
12747 25854 yofs+=16;
12748 25854 xofs=0;
12749 25854 tile=o_tile+((clk&16)?20:22);
12750 25854 enemy::draw(dest);
12751 25854 xofs=xblockofs;
12752 25854 tile=o_tile+((clk&16)?21:23);
12753 25854 enemy::draw(dest);
12754 25854 yofs-=16;
12755 25854 }
12756 else enemy::draw(dest);
12757 }
12758 72310 }
12759
12760 23834 bool eAquamentus::hit(weapon *w)
12761 {
12762
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12763
12764
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12765 {
12766 case wBeam:
12767 case wRefBeam:
12768 case wMagic:
12769 4201 hit_height=32;
12770 4201 }
12771
12772
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12773 23834 hit_height=16;
12774 23834 return ret;
12775
12776 23834 }
12777
12778 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12779 93 {
12780
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12781 {
12782
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12783 93 }
12784 else { x = X; y = Y; }
12785
12786 93 Clk=Clk;
12787
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12788 {
12789 clk=0;
12790 superman = 1;
12791 fading=fade_flicker;
12792 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12793 }
12794
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12795 {
12796 42 clk=0;
12797 42 }
12798 93 hxofs=-16;
12799 93 hit_width=48;
12800 93 clk4=0;
12801
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12802
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12804
12805 //nets+5340;
12806 93 }
12807
12808 70891 bool eGohma::animate(int32_t index)
12809 {
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12811
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12812 1226 return Dead(index);
12813
12814
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12815 {
12816
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12817 {
12818 35 clk4=0;
12819 35 superman=0;
12820 35 fading=0;
12821 35 clk=0;
12822
12823 35 }
12824 1 else return enemy::animate(index);
12825 35 }
12826
12827
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12828 {
12829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12830 else
12831 {
12832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12833 350 did_armos = false;
12834 350 removearmos(x,y);
12835 350 did_armos = false;
12836
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12837 }
12838 350 }
12839
12840
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12841
12842 // Movement clk must be separate from animation clk because of the Clock item
12843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12844 68878 clk4++;
12845
12846
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12847 {
12848
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12849 546 dir^=1;
12850 else
12851 486 dir=zc_oldrand()%3+1;
12852 1032 }
12853
12854
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12855 {
12856
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12857 {
12858 case 1:
12859 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12860 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12861 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12862 235 sfx(wpnsfx(wpn),pan(x));
12863 235 break;
12864
12865 default:
12866
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12867 {
12868 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12869 754 sfx(wpnsfx(wpn),pan(x));
12870 754 sfx(wpnsfx(wpn),pan(x));
12871 754 }
12872
12873 882 break;
12874 }
12875 1117 }
12876
12877
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12878 {
12879
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12880 {
12881 290 FireBreath(true);
12882 290 }
12883 2215 }
12884
12885
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12886 34479 move((zfix)1);
12887
12888
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12889 150 clk3=0;
12890
12891 68878 return enemy::animate(index);
12892 70891 }
12893
12894 70889 void eGohma::draw(BITMAP *dest)
12895 {
12896 70889 tile=o_tile;
12897
12898
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12899 {
12900 2012 enemy::drawzcboss(dest);
12901 2012 return;
12902 }
12903
12904
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12905 {
12906 ///if ( do_animation )
12907 //Yuck. Gohma can just not have this capability right now.
12908 // left side
12909 53472 xofs=-16;
12910 53472 flip=0;
12911 // if(clk&16) tile=180;
12912 // else { tile=182; flip=1; }
12913 53472 tile+=(3*((clk&48)>>4));
12914 53472 enemy::drawzcboss(dest);
12915
12916 // right side
12917 53472 xofs=16;
12918 // tile=(180+182)-tile;
12919 53472 tile=o_tile;
12920 53472 tile+=(3*((clk&48)>>4))+2;
12921 53472 enemy::drawzcboss(dest);
12922
12923 // body
12924 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12925 53472 tile=o_tile;
12926
12927 // tile+=(3*((clk&24)>>3))+2;
12928
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12929 2975 tile+=7;
12930
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12931 15890 tile+=10;
12932
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12933 2051 tile+=7;
12934 else
12935 32556 tile+=((clk3-132)&24)?4:1;
12936
12937 53472 enemy::drawzcboss(dest);
12938
12939 53472 }
12940 else
12941 {
12942 // left side
12943 15405 xofs=-16;
12944 15405 flip=0;
12945
12946
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12947 {
12948 7790 tile+=2;
12949 7790 flip=1;
12950 7790 }
12951
12952 15405 enemy::draw(dest);
12953
12954 // right side
12955 15405 tile=o_tile;
12956 15405 xofs=16;
12957
12958
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12959
12960 // tile=(180+182)-tile;
12961 15405 enemy::draw(dest);
12962
12963 // body
12964 15405 tile=o_tile;
12965 15405 xofs=0;
12966
12967
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12968 912 tile+=4;
12969
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12970 4882 tile+=5;
12971
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12972 585 tile+=4;
12973 9026 else tile+=((clk3-132)&8)?3:1;
12974
12975 15405 enemy::draw(dest);
12976
12977 }
12978 70889 }
12979
12980 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12981 {
12982 578 int32_t wpnId = w->id;
12983 578 int32_t power = w->power;
12984 578 int32_t wpnx = w->x;
12985 578 int32_t wpnDir = w->dir;
12986 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12987
12988
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12989 {
12990
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12991 {
12992 93 sfx(WAV_CHINK,pan(x));
12993 93 return 1;
12994 }
12995 328 }
12996
12997 485 return enemy::takehit(w, realweap);
12998 578 }
12999
13000 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13001 327 {
13002 327 count_enemy=(id==(id&0xFFF));
13003 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13004
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13005 327 }
13006
13007 124050 bool eLilDig::animate(int32_t index)
13008 {
13009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13010
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13011 4410 return Dead(index);
13012
13013
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13014 {
13015 7105 removearmos(x,y,ffcactivated);
13016 7105 }
13017
13018
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13019 {
13020
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13021 1161 step+=0.25;
13022 38646 }
13023
13024 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13025 119640 return enemy::animate(index);
13026 124050 }
13027
13028 124268 void eLilDig::draw(BITMAP *dest)
13029 {
13030 124268 tile = o_tile;
13031 // tile = 160;
13032 124268 int32_t fdiv = frate/4;
13033
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13034
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13035 124268 efrate:((clk>=(frate>>1))?1:0);
13036
13037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13038 {
13039
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13040 {
13041
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13042 {
13043 case up: //u
13044 11370 flip=0;
13045 11370 break;
13046
13047 case l_up: //d
13048 10699 flip=0;
13049 10699 tile+=4;
13050 10699 break;
13051
13052 case l_down: //l
13053 10722 flip=0;
13054 10722 tile+=8;
13055 10722 break;
13056
13057 case left: //r
13058 12015 flip=0;
13059 12015 tile+=12;
13060 12015 break;
13061
13062 case r_down: //ul
13063 10070 flip=0;
13064 10070 tile+=20;
13065 10070 break;
13066
13067 case down: //ur
13068 9554 flip=0;
13069 9554 tile+=24;
13070 9554 break;
13071
13072 case r_up: //dl
13073 8255 flip=0;
13074 8255 tile+=28;
13075 8255 break;
13076
13077 case right: //dr
13078 10033 flip=0;
13079 10033 tile+=32;
13080 10033 break;
13081 }
13082
13083 91457 tile+=f2;
13084 91457 }
13085 else
13086 {
13087 32811 tile+=(clk>=6)?1:0;
13088 }
13089 124268 }
13090
13091 124268 enemy::draw(dest);
13092 124268 }
13093
13094 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13095 80 {
13096
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13097 80 }
13098
13099 29662 bool eBigDig::animate(int32_t index)
13100 {
13101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13103 return Dead(index);
13104
13105
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13106 {
13107 4104 removearmos(x,y,ffcactivated);
13108 4104 }
13109
13110
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13111 {
13112 case 0:
13113 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13114 29534 break;
13115
13116 case 1:
13117 64 ++misc;
13118 64 break;
13119
13120 case 2:
13121
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13122 {
13123 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13124 111 }
13125
13126
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13127 {
13128 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13129 30 }
13130
13131
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13132 {
13133 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13134 30 }
13135
13136
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13137 {
13138 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13139 30 }
13140
13141
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13142 {
13143 2 int guycarryingitem = guys.Count()-1;
13144 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13145 2 itemguy = false;
13146 2 }
13147
13148 64 stop_bgsfx(index);
13149
13150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13151
13152 64 return true;
13153 }
13154
13155 29598 return enemy::animate(index);
13156 29662 }
13157
13158 29658 void eBigDig::draw(BITMAP *dest)
13159 {
13160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13161 {
13162 update_enemy_frame();
13163 xofs-=8;
13164 yofs-=8;
13165 drawblock(dest,15);
13166 xofs+=8;
13167 yofs+=8;
13168 return;
13169 }
13170
13171 29658 tile = o_tile;
13172 29658 int32_t fdiv = frate/4;
13173
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13174
13175
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13176 29658 efrate:((clk>=(frate>>1))?1:0);
13177
13178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13179 {
13180
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13181 {
13182
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13183 {
13184 case up: //u
13185 1688 flip=0;
13186 1688 break;
13187
13188 case l_up: //d
13189 1684 flip=0;
13190 1684 tile+=8;
13191 1684 break;
13192
13193 case l_down: //l
13194 2031 flip=0;
13195 2031 tile+=40;
13196 2031 break;
13197
13198 case left: //r
13199 1910 flip=0;
13200 1910 tile+=48;
13201 1910 break;
13202
13203 case r_down: //ul
13204 2041 flip=0;
13205 2041 tile+=80;
13206 2041 break;
13207
13208 case down: //ur
13209 2043 flip=0;
13210 2043 tile+=88;
13211
13212 2043 break;
13213
13214 case r_up: //dl
13215 1514 flip=0;
13216 1514 tile+=120;
13217 1514 break;
13218
13219 case right: //dr
13220 2241 flip=0;
13221 2241 tile+=128;
13222 2241 break;
13223 }
13224
13225 16161 tile+=(f2*2);
13226 16161 }
13227 else
13228 {
13229 13497 tile+=(f2)?0:2;
13230 13497 flip=(clk&1)?1:0;
13231 }
13232 29658 }
13233
13234 29658 xofs-=8;
13235 29658 yofs-=8;
13236 29658 drawblock(dest,15);
13237 29658 xofs+=8;
13238 29658 yofs+=8;
13239 29658 }
13240
13241 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13242 {
13243 869 int32_t wpnId = w->id;
13244
13245
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13246 {
13247 64 misc = 1;
13248 64 w->hit_pierce(this, 0, false);
13249 64 }
13250
13251 869 return 0;
13252 }
13253
13254 80 void eBigDig::init_size_flags()
13255 {
13256 80 SIZEflags = d->SIZEflags;
13257
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13258 // al_trace("Enemy txsz:%i\n", txsz);
13259
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13261 80 else hit_width = 32;
13262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13263 80 else hit_height = 32;
13264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13265 80 else hzsz = 16; // hard to jump.
13266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13267 80 else hxofs = -8;
13268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13269 80 else hyofs = -8;
13270 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13271
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13272
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13273 {
13274 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13275 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13276 }
13277
13278
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13279 80 }
13280
13281 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13282 13 {
13283 13 hxofs=hyofs=8;
13284
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13285 {
13286 hxofs = 4;
13287 hyofs = 4;
13288 hit_width = 24;
13289 hit_height = 24;
13290 SIZEflags|=OVERRIDE_HIT_WIDTH;
13291 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13292 }
13293 13 hzsz=16; //can't be jumped.
13294 13 clk2=70;
13295 13 misc=-1;
13296
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13297
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13298 13 }
13299
13300 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13301 {
13302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13303
13304 return Dead(index);
13305
13306
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13307 {
13308 72 removearmos(x,y,ffcactivated);
13309 72 }
13310
13311
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13312 {
13313 case -1:
13314 13 misc=0;
13315 [[fallthrough]];
13316 case 0:
13317
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13318 {
13319 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13320 173 sfx(wpnsfx(wpn),pan(x));
13321 173 clk2=0;
13322 173 }
13323
13324 12693 Stunclk=0;
13325 12693 constant_walk(rate,homing,spw_none);
13326 12693 break;
13327
13328 case 1:
13329 case 2:
13330
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13331 {
13332 41 int32_t r=zc_oldrand();
13333
13334
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13335 {
13336 17 y=96;
13337
13338
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13339 6 x=160;
13340 else
13341 11 x=48;
13342
13343
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13344 8 x=208-x;
13345
13346 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13347 17 }
13348
13349 41 loadpalset(csBOSS,pSprite(d->bosspal));
13350 41 misc=0;
13351 41 }
13352
13353 3607 break;
13354
13355 case 3:
13356 {
13357
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13358 972 break;
13359
13360 12 misc=4;
13361 12 clk=0;
13362 12 hxofs=1000;
13363 12 loadpalset(9,pSprite(spPILE));
13364 12 music_stop();
13365 12 stop_sfx(WAV_ROAR);
13366
13367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13368
13369 12 sfx(WAV_GANON);
13370 //Ganon's dustpile; fall in sideview. -Z
13371 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13372 //dustpile->miscellaneous[31] = eeGANON;
13373
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13374 12 item *dustpile = NULL;
13375 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13376 12 dustpile = (item *)items.spr(items.Count() - 1);
13377 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13378 12 break;
13379 }
13380
13381 case 4:
13382
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13383 {
13384 12 misc=5;
13385
13386 //game->lvlitems[dlevel]|=liBOSS;
13387
13388 12 sfx(WAV_CLEARED);
13389 //Add the big TF over the ashes!
13390
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13391 {
13392 24 item *ashes = (item*)items.spr(q);
13393
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13394 {
13395 //Z_scripterrlog("Found correct dustpile!\n");
13396
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13397 12 item *bigtriforce = NULL;
13398 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13399 12 bigtriforce->linked_parent = eeGANON;
13400 12 }
13401 24 }
13402 12 }
13403
13404 960 break;
13405 10 case 5: return true;
13406 }
13407
13408 18244 return enemy::animate(index);
13409 18254 }
13410
13411
13412 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13413 {
13414 //these are here to bypass compiler warnings about unused arguments
13415 964 int32_t wpnId = w->id;
13416 964 int32_t power = w->power;
13417 964 int32_t enemyHitWeapon = w->parentitem;
13418
13419
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13420 {
13421 case 0:
13422
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13423 31 return 0;
13424
13425 53 hp-=power;
13426
13427
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13428 {
13429 41 misc=1;
13430 41 Stunclk=64;
13431 41 }
13432 else
13433 {
13434 12 loadpalset(csBOSS,pSprite(spBROWN));
13435 12 misc=2;
13436 12 Stunclk=284;
13437 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13438 }
13439
13440 53 sfx(WAV_EHIT,pan(x));
13441
13442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13443
13444 53 return 1;
13445
13446 case 2:
13447
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13448 154 return 0;
13449
13450 12 misc=3;
13451 12 hclk=81;
13452 12 loadpalset(9,pSprite(spBROWN));
13453 12 return 1;
13454 }
13455
13456 714 return 0;
13457 964 }
13458
13459 20776 void eGanon::draw(BITMAP *dest)
13460 {
13461
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13462 {
13463 case 0:
13464
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13465 3169 tile=(zc_oldrand()%5)*2+o_tile;
13466
13467
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13468 {
13469
13470 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13471 {
13472 int odraw = drawstyle;
13473 drawstyle = 2;
13474 drawblock(dest,15);
13475 drawstyle = odraw;
13476 }
13477 else
13478 {
13479 drawblock(dest,15);
13480 }
13481 break;
13482
13483 }
13484
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13485 {
13486 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13487 {
13488 int odraw = drawstyle;
13489 drawstyle = 2;
13490 drawblock(dest,15);
13491 drawstyle = odraw;
13492 }
13493 else
13494 {
13495 drawblock(dest,15);
13496 }
13497 break;
13498 }
13499
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13500 12680 break;
13501 [[fallthrough]];
13502 case 2:
13503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13504 break;
13505 [[fallthrough]];
13506 case -1:
13507 3518 tile=o_tile;
13508
13509 [[fallthrough]];
13510 case 1:
13511 case 3:
13512 7126 drawblock(dest,15);
13513 7126 break;
13514
13515 case 4:
13516 960 draw_guts(dest);
13517 960 draw_flash(dest);
13518 960 break;
13519 }
13520 20776 }
13521
13522 960 void eGanon::draw_guts(BITMAP *dest)
13523 {
13524
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13525 960 tile = clk<24 ? 74 : 75;
13526 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13527 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13528 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13529 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13530 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13531 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13532 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13533 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13534 960 }
13535
13536 960 void eGanon::draw_flash(BITMAP *dest)
13537 {
13538
13539 960 int32_t c = clk-(clk>>2);
13540 960 cs = (frame&3)+6;
13541 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13542 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13543 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13544 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13545 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13546 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13547 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13548 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13549 960 }
13550
13551 15 void getBigTri(mapscr* scr, int32_t id2)
13552 {
13553 /*
13554 *************************
13555 * BIG TRIFORCE SEQUENCE *
13556 *************************
13557 0 BIGTRI out, WHITE flash in
13558 4 WHITE flash out, PILE cset white
13559 8 WHITE in
13560 ...
13561 188 WHITE out
13562 191 PILE cset red
13563 200 top SHUTTER opens
13564 209 bottom SHUTTER opens
13565 */
13566 15 sfx(itemsbuf[id2].playsound);
13567 15 guys.clear();
13568
13569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13570 {
13571 game->lvlitems[dlevel]|=liTRIFORCE;
13572 }
13573
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13575
13576 15 draw_screen();
13577
13578
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13579 {
13580
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13581 {
13582
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13583 {
13584 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13585 225 }
13586 15 }
13587
13588
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13589 {
13590
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13591 {
13592
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13593 {
13594 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13595 16200 }
13596 1080 }
13597
13598 360 refreshpal=true;
13599 360 }
13600
13601
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13602 {
13603
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13604 else loadlvlpal(0xB);
13605 360 }
13606
13607
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13608 {
13609 15 loadpalset(9,pSprite(spPILE));
13610 15 }
13611
13612 2880 advanceframe(true);
13613 2880 }
13614
13615 //play_DmapMusic();
13616 15 playLevelMusic();
13617
13618
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13619 {
13620 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13621 2 }
13622 15 }
13623
13624 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13625 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13626 618 {
13627
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13628 {
13629
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13630 618 }
13631 //else { x = X; y = Y; }
13632
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13633 618 superman=1;
13634 618 fading=fade_invisible;
13635 618 hxofs=1000;
13636 618 segcnt=clk;
13637 618 segid=Id|0x1000;
13638 618 clk=0;
13639
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13640
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13641 618 tile=o_tile;
13642 618 hitdir = -1;
13643 618 stickclk = 0;
13644
13645 /*
13646 if (get_qr(qr_NEWENEMYTILES))
13647 {
13648 tile=nets+1220;
13649 }
13650 else
13651 {
13652 tile=57;
13653 }
13654 */
13655 618 }
13656
13657 244844 bool eMoldorm::animate(int32_t index)
13658 {
13659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13660 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13661
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13662 {
13663 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13664 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13665 28475 }
13666
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13667 {
13668 562 stickclk = 0;
13669 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13670 562 }
13671
13672
13673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13674 {
13675 244844 removearmos(x,y,ffcactivated);
13676 244844 }
13677
13678
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13679 {
13680
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13681 {
13682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13683 129 never_return(screen_spawned, index);
13684
13685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13686 129 leave_item();
13687
13688 129 stop_bgsfx(index);
13689 129 return true;
13690 }
13691 2322 }
13692 else
13693 {
13694
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13695 stunclk=0;
13696 242393 constant_walk_8_old(rate,homing,spw_floater);
13697
13698
13699 242393 misc=dir;
13700
13701 // If any higher-numbered segments were killed, segcnt can be too high,
13702 // leading to a crash
13703
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13704 segcnt=guys.Count()-index-1;
13705
13706
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13707 {
13708 1122281 enemy* segment=((enemy*)guys.spr(i));
13709
13710 // More validation - if segcnt was wrong, this may not
13711 // actually be a Moldorm segment
13712
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13713 {
13714 segcnt=i-index-1;
13715 break;
13716 }
13717
13718
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13719 {
13720 242669 x=segment->x;
13721 242669 y=segment->y;
13722 242669 }
13723
13724 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13725 //Script your own blasted segmented bosses!! -Z
13726 1122281 segment->setParent(this);
13727
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13728 {
13729 217733 segment->dummy_int[1]=2;
13730 217733 }
13731 else
13732 {
13733 904548 segment->dummy_int[1]=1;
13734 }
13735
13736
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13737 {
13738 242669 segment->dummy_int[1]=0;
13739 242669 }
13740
13741
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13742 {
13743 1016 int32_t offset=1;
13744
13745
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13746 {
13747 // Triple-check
13748
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13749 {
13750 segcnt=j-index+1; // Add 1 because of --segcnt below
13751 break;
13752 }
13753 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13754 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13755 1480 }
13756
13757 1016 segment->hclk=33;
13758 1016 --segcnt;
13759 1016 --i; // Recheck the same index in case multiple segments died at once
13760 1016 }
13761 1122281 }
13762
13763
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13764 {
13765 129 clk2=19;
13766
13767 129 x=guys.spr(index+1)->x;
13768 129 y=guys.spr(index+1)->y;
13769 129 }
13770 }
13771
13772 244715 return false;
13773 244844 }
13774
13775 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13776 3150 {
13777
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13778 {
13779
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13780 3150 }
13781
13782
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13783 3150 hyofs=4;
13784 3150 hit_width=hit_height=8;
13785 3150 hxofs=1000;
13786 3150 mainguy=count_enemy=false;
13787 3150 parentclk = 0;
13788 3150 bgsfx=-1;
13789
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13790 //deadsfx = WAV_EDEAD;
13791 3150 isCore = false;
13792 3150 }
13793
13794 1138024 bool esMoldorm::animate(int32_t index)
13795 {
13796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13797 // Shouldn't be possible, but better to be sure
13798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13799 dying=true;
13800
13801
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13802 {
13803
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13804 15743 item_set=0;
13805
13806 15743 return Dead(index);
13807 }
13808
13809
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13810 {
13811 1017204 hxofs=4;
13812 1017204 step=((enemy*)guys.spr(index-1))->step;
13813
13814
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13815 {
13816 70455 misc=dir;
13817 70455 dir=((enemy*)guys.spr(index-1))->misc;
13818 //do alignment, as in parent's animation :-/ -DD
13819 70455 x.doFloor();
13820 70455 y.doFloor();
13821 70455 }
13822
13823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13824 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13825
13826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13827 {
13828 1017204 sprite::move(step);
13829 1017204 }
13830 1017204 }
13831
13832 1122281 return enemy::animate(index);
13833 1138024 }
13834
13835 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13836 {
13837
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13838 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13839
13840 453 return 0;
13841 2683 }
13842
13843 1155313 void esMoldorm::draw(BITMAP *dest)
13844 {
13845 1155313 tile=o_tile;
13846 1155313 int32_t fdiv = frate/4;
13847
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13848
13849
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13850 1155313 efrate:((clk>=(frate>>1))?1:0);
13851
13852
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13853 {
13854 1043930 tile+=dummy_int[1]*40;
13855
13856
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13857 {
13858 102730 flip=0;
13859
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13860
13861
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13862 tile+=4;
13863 102730 }
13864 else
13865 {
13866
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13867 {
13868 case up: //u
13869 96530 flip=0;
13870 96530 break;
13871
13872 case l_up: //d
13873 134534 flip=0;
13874 134534 tile+=4;
13875 134534 break;
13876
13877 case l_down: //l
13878 113426 flip=0;
13879 113426 tile+=8;
13880 113426 break;
13881
13882 case left: //r
13883 124800 flip=0;
13884 124800 tile+=12;
13885 124800 break;
13886
13887 case r_down: //ul
13888 101314 flip=0;
13889 101314 tile+=20;
13890 101314 break;
13891
13892 case down: //ur
13893 99043 flip=0;
13894 99043 tile+=24;
13895 99043 break;
13896
13897 case r_up: //dl
13898 131794 flip=0;
13899 131794 tile+=28;
13900 131794 break;
13901
13902 case right: //dr
13903 139759 flip=0;
13904 139759 tile+=32;
13905 139759 break;
13906 }
13907 }
13908
13909 1043930 tile+=f2;
13910 1043930 }
13911
13912
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13913 1049046 enemy::draw(dest);
13914 1155313 }
13915
13916 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13917 420 {
13918
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13919 {
13920
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13921 420 }
13922 //else { x = X; y = Y; }
13923 //byte legaldirs = 0;
13924 420 int32_t incr = 16;
13925 //int32_t possiiblepos = 0;
13926 //int32_t positions[8] = {0};
13927
13928 //Don't spawn in pits.
13929
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13930 {
13931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13932 {
13933 //move if we spawn over a pit
13934 //check each direction
13935
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13936 {
13937
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13938 }
13939
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13940 {
13941
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13942 }
13943
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13944 {
13945
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13946 }
13947
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13948 {
13949
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13950 }
13951
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13952 {
13953 y -= incr; break;
13954 }
13955
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13956 {
13957 y+=incr; break;
13958 }
13959
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13960 {
13961
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13962 }
13963
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13964 {
13965 x+=incr; y+=incr; break;
13966 }
13967 34 else continue;
13968
13969 }
13970
13971 105 }
13972
13973 420 dir=up;
13974 420 superman=1;
13975 420 fading=fade_invisible;
13976 420 hxofs=1000;
13977 420 segcnt=clk;
13978 420 clk=0;
13979 //set up move history
13980
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13981
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13982 420 }
13983
13984 236907 bool eLanmola::animate(int32_t index)
13985 {
13986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13987
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13988 {
13989 40196 removearmos(x,y,ffcactivated);
13990 40196 }
13991
13992
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13993 {
13994
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13995 {
13996
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13997 86 leave_item();
13998
13999 189 stop_bgsfx(index);
14000 189 return true;
14001 }
14002
14003 3402 return false;
14004 }
14005
14006
14007 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14008 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14009 //I've added a complete movement history to this enemy to compensate -DD
14010 233316 constant_walk(rate,homing,spw_none);
14011 233316 prevState.pop_front();
14012 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14013
14014 // This could cause a crash with Moldorms. I didn't see the same problem
14015 // with Lanmolas, but it looks like it ought to be possible, so here's
14016 // the same solution. - Saf
14017
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14018 segcnt=guys.Count()-index-1;
14019
14020
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14021 {
14022 966396 enemy* segment=((enemy*)guys.spr(i));
14023
14024 // More validation in case segcnt is wrong
14025
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14026 {
14027 segcnt=i-index-1;
14028 break;
14029 }
14030
14031 966396 segment->o_tile=o_tile;
14032 966396 segment->setParent(this);
14033
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14034 {
14035 195700 segment->dummy_int[1]=1; //tail
14036 195700 }
14037 else
14038 {
14039 770696 segment->dummy_int[1]=0;
14040 }
14041
14042
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14043 {
14044
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14045 {
14046 // Triple-check
14047
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14048 {
14049 segcnt=j-index+1; // Add 1 because of --segcnt below
14050 break;
14051 }
14052 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14053 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14054 1961 }
14055
14056 1169 ((enemy*)guys.spr(i))->hclk=33;
14057 1169 --segcnt;
14058 1169 --i; // Recheck the same index in case multiple segments died at once
14059 1169 }
14060 966396 }
14061
14062
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14063 {
14064 189 clk2=19;
14065 189 x=guys.spr(index+1)->x;
14066 189 y=guys.spr(index+1)->y;
14067 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14068 189 }
14069
14070 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14071 //which is... disastrous.
14072 233316 hp = 1;
14073 233316 return enemy::animate(index);
14074 236907 }
14075
14076 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14077 2267 {
14078
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14079 {
14080
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14081 2267 }
14082 2267 int32_t incr = 16;
14083 //Don't spawn in pits.
14084
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14085 {
14086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14087 {
14088 //move if we spawn over a pit
14089 //check each direction
14090
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14091 {
14092
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14093 }
14094
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14095 {
14096
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14097 }
14098
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14099 {
14100
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14101 }
14102
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14103 {
14104
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14105 }
14106
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14107 {
14108 y -= incr; break;
14109 }
14110
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14111 {
14112 y+=incr; break;
14113 }
14114
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14115 {
14116
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14117 }
14118
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14119 {
14120 x+=incr; y+=incr; break;
14121 }
14122 170 else continue;
14123
14124 }
14125
14126 525 }
14127
14128 2267 hxofs=1000;
14129 2267 hit_width=8;
14130 2267 mainguy=false;
14131 2267 count_enemy=(id<0x2000)?true:false;
14132
14133 //set up move history
14134
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14135
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14136
14137 2267 bgsfx = -1;
14138 2267 isCore = false;
14139
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14140 2267 }
14141
14142 985563 bool esLanmola::animate(int32_t index)
14143 {
14144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14145 // Shouldn't be possible, but who knows
14146
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14147 18 dying=true;
14148
14149
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14150 {
14151 19167 xofs=0;
14152
14153
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14154 9306 item_set=0;
14155
14156 19167 return Dead(index);
14157 }
14158
14159
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14160 {
14161 930450 hxofs=4;
14162
14163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14164 {
14165 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14166 930450 prevState.pop_front();
14167 930450 prevState.push_back(newstate);
14168 930450 x = newstate.first.first;
14169 930450 y = newstate.first.second;
14170 930450 dir = newstate.second;
14171 930450 }
14172 930450 }
14173
14174 966396 return enemy::animate(index);
14175 985563 }
14176
14177 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14178 {
14179
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14180 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14181
14182 590 return 0;
14183 2655 }
14184
14185 990931 void esLanmola::draw(BITMAP *dest)
14186 {
14187 990931 tile=o_tile;
14188 990931 int32_t fdiv = frate/4;
14189
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14190
14191
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14192 990931 efrate:((clk>=(frate>>1))?1:0);
14193
14194
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14195 {
14196
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14197 {
14198 481767 tile+=20;
14199
14200
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14201 {
14202 128742 tile+=20;
14203 128742 }
14204 481767 }
14205
14206
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14207 {
14208 case up:
14209 141419 flip=0;
14210 141419 break;
14211
14212 case down:
14213 140994 flip=0;
14214 140994 tile+=4;
14215 140994 break;
14216
14217 case left:
14218 159500 flip=0;
14219 159500 tile+=8;
14220 159500 break;
14221
14222 case right:
14223 187019 flip=0;
14224 187019 tile+=12;
14225 187019 break;
14226 }
14227
14228 628932 tile+=f2;
14229 628932 }
14230 else
14231 {
14232
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14233 {
14234 271456 tile+=1;
14235 271456 }
14236 }
14237
14238
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14239 953893 enemy::draw(dest);
14240 990931 }
14241
14242 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14243 150 {
14244 //these are here to bypass compiler warnings about unused arguments
14245 150 Clk=Clk;
14246 150 superman=1;
14247
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14248 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14249
14250
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14251 692 arm[i]=i;
14252
14253 150 fading=fade_blue_poof;
14254 //nets+4680;
14255 150 adjusted=false;
14256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14257 150 }
14258
14259 66494 bool eManhandla::animate(int32_t index)
14260 {
14261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14262
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14263 1382 return Dead(index);
14264
14265
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14266 {
14267 2471 removearmos(x,y,ffcactivated);
14268 2471 }
14269
14270
14271 // check arm status, move dead ones to end of group
14272
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14273 {
14274 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14275
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14276 {
14277
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14278 {
14279 552 zc_swap(arm[j],arm[j+1]);
14280 552 guys.swap(index+j+1,index+j+2);
14281 552 }
14282
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14283 {
14284 87 leave_item();
14285 87 }
14286 424 --armcnt;
14287 424 --i;
14288 424 continue;
14289 }
14290
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14291 {
14292
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14293 {
14294 508 cur_arm->o_tile=o_tile+40;
14295 508 cur_arm->setParent(this);
14296 508 }
14297 else
14298 {
14299 184 cur_arm->o_tile=o_tile+160;
14300 184 cur_arm->setParent(this);
14301 }
14302 692 }
14303 193194 }
14304
14305 65112 adjusted=true;
14306
14307 // move or die
14308
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14309 83 hp=0;
14310 else
14311 {
14312 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14313
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14314
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14315 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14316
14317
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14318 {
14319
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14320 {
14321
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14322 {
14323 case 0:
14324 38579 dy1=-24;
14325 38579 break;
14326
14327 case 1:
14328 36328 dy2=31;
14329 36328 break;
14330
14331 case 2:
14332 36250 dx1=-16;
14333 36250 break;
14334
14335 case 3:
14336 39862 dx2=31;
14337 39862 break;
14338 }
14339 151019 }
14340 53584 }
14341 else
14342 {
14343 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14344
14345
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14346 {
14347
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14348 {
14349 case 0:
14350 12012 dy1=-32;
14351 12012 break;
14352
14353 case 1:
14354 7730 dy2=39;
14355 7730 break;
14356
14357 case 2:
14358 9837 dx1=-24;
14359 9837 break;
14360
14361 case 3:
14362 12596 dx2=39;
14363 12596 break;
14364 }
14365 42175 }
14366 }
14367
14368 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14369
14370
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14371 {
14372 193194 zfix dx=(zfix)0,dy=(zfix)0;
14373
14374
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14375 {
14376
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14377 {
14378 case 0:
14379 38579 dy=-16;
14380 38579 break;
14381
14382 case 1:
14383 36328 dy=16;
14384 36328 break;
14385
14386 case 2:
14387 36250 dx=-16;
14388 36250 break;
14389
14390 case 3:
14391 39862 dx=16;
14392 39862 break;
14393 }
14394 151019 }
14395 else
14396 {
14397
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14398 {
14399 case 0:
14400 5447 dy=-24;
14401 5447 dx=-8;
14402 5447 break;
14403
14404 case 1:
14405 3986 dy=24;
14406 3986 dx=8;
14407 3986 break;
14408
14409 case 2:
14410 4163 dx=-24;
14411 4163 dy=8;
14412 4163 break;
14413
14414 case 3:
14415 6774 dx=24;
14416 6774 dy=-8;
14417 6774 break;
14418
14419 case 4:
14420 6565 dy=-24;
14421 6565 dx=8;
14422 6565 break;
14423
14424 case 5:
14425 3744 dy=24;
14426 3744 dx=-8;
14427 3744 break;
14428
14429 case 6:
14430 5674 dx=-24;
14431 5674 dy=-8;
14432 5674 break;
14433
14434 case 7:
14435 5822 dx=24;
14436 5822 dy=8;
14437 5822 break;
14438 }
14439 }
14440
14441 193194 guys.spr(index+i+1)->x = x+dx;
14442 193194 guys.spr(index+i+1)->y = y+dy;
14443 193194 }
14444 }
14445
14446 65112 return enemy::animate(index);
14447 66494 }
14448
14449
14450 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14451 {
14452 1751 int32_t wpnId = w->id;
14453
14454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14455 return 0;
14456
14457
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14458 {
14459 case wBomb:
14460 case wSBomb:
14461 case wSword:
14462 case wHammer:
14463 case wWand:
14464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14465
14466 case wLitBomb:
14467 case wLitSBomb:
14468 case wBait:
14469 case wWhistle:
14470 case wFire:
14471 case wWind:
14472 case wSSparkle:
14473 case wFSparkle:
14474 case wPhantom:
14475 1709 return 0;
14476
14477 case wHookshot:
14478 case wBrang:
14479 sfx(WAV_CHINK,pan(x));
14480 break;
14481
14482 default:
14483
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14484 else sfx(WAV_CHINK,pan(x));
14485
14486 42 }
14487
14488 42 return 1;
14489 1751 }
14490
14491 66490 void eManhandla::draw(BITMAP *dest)
14492 {
14493 66490 tile=o_tile;
14494 66490 int32_t fdiv = frate/4;
14495
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14496
14497
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14498 66490 efrate:((clk>=(frate>>1))?1:0);
14499
14500
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14501 {
14502
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14503 {
14504
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14505 {
14506 case up: //u
14507 4771 flip=0;
14508 4771 break;
14509
14510 case l_up: //d
14511 4640 flip=0;
14512 4640 tile+=4;
14513 4640 break;
14514
14515 case l_down: //l
14516 4995 flip=0;
14517 4995 tile+=8;
14518 4995 break;
14519
14520 case left: //r
14521 5574 flip=0;
14522 5574 tile+=12;
14523 5574 break;
14524
14525 case r_down: //ul
14526 3793 flip=0;
14527 3793 tile+=20;
14528 3793 break;
14529
14530 case down: //ur
14531 3930 flip=0;
14532 3930 tile+=24;
14533 3930 break;
14534
14535 case r_up: //dl
14536 3908 flip=0;
14537 3908 tile+=28;
14538 3908 break;
14539
14540 case right: //dr
14541 5883 flip=0;
14542 5883 tile+=32;
14543 5883 break;
14544 }
14545
14546 37494 tile+=f2;
14547 37494 enemy::draw(dest);
14548 37494 } //manhandla 2, big body
14549 else
14550 {
14551
14552
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14553 {
14554 case up: //u
14555 1277 flip=0;
14556 1277 break;
14557
14558 case l_up: //d
14559 1360 flip=0;
14560 1360 tile+=8;
14561 1360 break;
14562
14563 case l_down: //l
14564 2242 flip=0;
14565 2242 tile+=40;
14566 2242 break;
14567
14568 case left: //r
14569 1789 flip=0;
14570 1789 tile+=48;
14571 1789 break;
14572
14573 case r_down: //ul
14574 1345 flip=0;
14575 1345 tile+=80;
14576 1345 break;
14577
14578 case down: //ur
14579 805 flip=0;
14580 805 tile+=88;
14581 805 break;
14582
14583 case r_up: //dl
14584 948 flip=0;
14585 948 tile+=120;
14586 948 break;
14587
14588 case right: //dr
14589 1542 flip=0;
14590 1542 tile+=128;
14591 1542 break;
14592 }
14593
14594 11308 tile+=(f2*2);
14595 11308 xofs-=8;
14596 11308 yofs-=8;
14597 11308 drawblock(dest,15);
14598 11308 xofs+=8;
14599 11308 yofs+=8;
14600 }
14601 48802 }
14602 else
14603 {
14604
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14605 {
14606 17173 enemy::draw(dest);
14607 17173 }
14608 else
14609 {
14610 515 xofs-=8;
14611 515 yofs-=8;
14612 515 enemy::draw(dest);
14613 515 xofs+=16;
14614 515 enemy::draw(dest);
14615 515 yofs+=16;
14616 515 enemy::draw(dest);
14617 515 xofs-=16;
14618 515 enemy::draw(dest);
14619 515 xofs+=8;
14620 515 yofs-=8;
14621 }
14622 }
14623 66490 }
14624
14625 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14626 692 {
14627 692 id=misc=clk;
14628 692 dir = clk & 3;
14629 692 clk=0;
14630 692 mainguy=count_enemy=false;
14631 692 dummy_bool[0]=false;
14632 692 item_set=0;
14633 692 bgsfx=-1;
14634 692 deadsfx = WAV_EDEAD;
14635
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14636 692 isCore = false;
14637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14638 692 }
14639
14640 200202 bool esManhandla::animate(int32_t index)
14641 {
14642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14643
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14644 7008 return Dead(index);
14645
14646
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14647 {
14648 12404 removearmos(x,y,ffcactivated);
14649 12404 }
14650
14651
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14652 {
14653 27896 clk2=unsigned(zc_oldrand())%5+5;
14654 27896 clk3^=1;
14655 27896 }
14656
14657
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14658 {
14659 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14660 1491 sfx(wpnsfx(wpn),pan(x));
14661 1491 }
14662
14663 193194 return enemy::animate(index);
14664 200202 }
14665
14666 200186 void esManhandla::draw(BITMAP *dest)
14667 {
14668 200186 tile=o_tile;
14669 200186 int32_t fdiv = frate/4;
14670
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14671
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14672 200186 efrate:((clk>=(frate>>1))?1:0);
14673
14674
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14675 {
14676
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14677 {
14678 case up:
14679 39945 break;
14680
14681 case down:
14682 36845 tile+=4;
14683 36845 break;
14684
14685 case left:
14686 39966 tile+=8;
14687 39966 break;
14688
14689 case right:
14690 41960 tile+=12;
14691 41960 break;
14692 }
14693
14694 158716 tile+=f2;
14695 158716 }
14696 else
14697 {
14698
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14699 {
14700 case down:
14701 8961 flip=2;
14702
14703 [[fallthrough]];
14704 case up:
14705 21355 tile=(clk3)?188:189;
14706 21355 break;
14707
14708 case right:
14709 12232 flip=1;
14710 [[fallthrough]];
14711
14712 case left:
14713 20115 tile=(clk3)?186:187;
14714 20115 break;
14715 }
14716 }
14717
14718 200186 enemy::draw(dest);
14719 200186 }
14720
14721 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14722 168 {
14723
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14724 {
14725
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14726 168 }
14727 else
14728 {
14729 if ( !(editorflags & ENEMY_FLAG6) )
14730 {
14731 x = X; y = Y;
14732 }
14733 else
14734 {
14735 x = X+8; y = Y;
14736 }
14737 }
14738 168 hzsz = 32; // can't be jumped.
14739 168 flameclk=0;
14740 168 misc=clk; // total head count
14741 168 clk3=clk; // live head count
14742 168 clk=0;
14743 168 clk2=60; // fire ball clock
14744 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14745
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14746 168 dir = down;
14747 168 hxofs=4;
14748 168 hit_width=8;
14749 // frate=17*4;
14750 168 fading=fade_blue_poof;
14751 //nets+5420;
14752
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14753 {
14754 /*
14755 necktile=o_tile+8;
14756 if (dmisc3)
14757 {
14758 necktile+=8;
14759 }
14760 */
14761 133 necktile=o_tile+dmisc6;
14762 133 }
14763 else
14764 {
14765 35 necktile=s_tile;
14766 }
14767 168 }
14768
14769 155290 bool eGleeok::animate(int32_t index)
14770 {
14771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14772
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14773 2199 return Dead(index);
14774
14775
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14776 {
14777 684 removearmos(x,y,ffcactivated);
14778 684 }
14779
14780 // Check if a head was killed somehow...
14781
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14782 51372 clk3=guys.Count()-index-1;
14783
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14784 87041 misc=guys.Count()-index-1;
14785
14786 //fix for the "kill all enemies" item
14787
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14788 {
14789
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14790 {
14791 // I haven't seen this fail, but it seems like it ought to be
14792 // possible, so I'm checking for it. - Saf
14793
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14794 break;
14795 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14796 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14797 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14798 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14799 12 }
14800
14801 6 clk3=0;
14802
14803
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14804 {
14805
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14806 break;
14807 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14808 12 }
14809 6 }
14810
14811
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14812 {
14813 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14814 403171 head->dummy_int[1]=necktile;
14815 403171 head->setParent(this);
14816
14817
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14818 {
14819 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14820 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14821 320127 }
14822 else
14823 {
14824 83044 head->dummy_int[2]=necktile+1; //connected head tile
14825 83044 head->dummy_int[3]=necktile+2; //flying head tile
14826 }
14827
14828 403171 head->dmisc5=dmisc5; //neck segments
14829
14830 /*
14831 if (dmisc3)
14832 {
14833 head->dummy_bool[0]=true;
14834 }
14835 */
14836
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14837 {
14838
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14839 {
14840 1228 hp -= 1000 - head->hp;
14841 1228 hclk = 33;
14842
14843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14844
14845 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14846 1228 }
14847
14848 5655 head->hclk = 0;
14849 5655 }
14850
14851 // Must be set in case of naughty ZScripts
14852 403171 head->hp = 1000;
14853 403171 }
14854
14855
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14856 {
14857 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14858 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14859 415 }
14860
14861
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14862 {
14863
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14864 {
14865 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14866 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14867 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14868 1287 sfx(wpnsfx(wpn),pan(x));
14869 1287 clk2=0;
14870 1287 }
14871 95682 }
14872 else
14873 {
14874
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14875 {
14876 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14877 557 head->timer=zc_oldrand()%50+50;
14878 557 clk2=0;
14879 557 }
14880 }
14881
14882
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14883 {
14884
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14885 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14886
14887
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14888 127 }
14889
14890 153091 return enemy::animate(index);
14891 155290 }
14892
14893 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14894 {
14895 1239 return 0;
14896 }
14897
14898 156918 void eGleeok::draw(BITMAP *dest)
14899 {
14900 156918 tile=o_tile;
14901
14902
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14903 {
14904 2199 enemy::draw(dest);
14905 2199 return;
14906 }
14907
14908 154719 int32_t f=clk/17;
14909
14910
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14911 {
14912 // body
14913 120524 xofs=-8;
14914 120524 yofs=32;
14915
14916
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14917
14918 {
14919 case 0:
14920 9155 tile+=0;
14921 9155 break;
14922
14923 case 1:
14924 10095 tile+=2;
14925 10095 break;
14926
14927 case 2:
14928 8686 tile+=4;
14929 8686 break;
14930
14931 default:
14932 92588 tile+=6;
14933 92588 break;
14934 }
14935 120524 }
14936 else
14937 {
14938 // body
14939 34195 xofs=-8;
14940 34195 yofs=32;
14941
14942
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14943 {
14944 case 0:
14945 2514 tile+=0;
14946 2514 break;
14947
14948 case 2:
14949 2459 tile+=4;
14950 2459 break;
14951
14952 default:
14953 29222 tile+=2;
14954 29222 break;
14955 }
14956 }
14957
14958 154719 enemy::drawblock(dest,15);
14959 156918 }
14960
14961 156918 void eGleeok::draw2(BITMAP *dest)
14962 {
14963 // the neck stub
14964 156918 tile=necktile;
14965 156918 xofs=0;
14966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14967
14968
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14969 {
14970 122181 tile+=((clk&24)>>3);
14971 122181 }
14972
14973
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14974 {
14975 154719 mapscr* scr = get_scr(screen_spawned);
14976
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14977 737 sprite::drawcloaked(dest);
14978 else
14979 153982 sprite::draw(dest);
14980 154719 }
14981 156918 }
14982
14983
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14984 533 {
14985
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14986
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14987
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14988 // dummy_bool[0]=false;
14989 533 timer=0;
14990 /* fixing */
14991 533 hp=1000;
14992
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14993 533 item_set=0;
14994
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14995
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14996 533 hxofs=4;
14997 533 hit_width=8;
14998
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14999 533 clk2=clk; // how int32_t to wait before moving first time
15000 533 clk=0;
15001 533 mainguy=count_enemy=false;
15002
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15003 533 clk3=((dir&2)>>1)+2; // left or right
15004 533 dir&=1; // up or down
15005
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15006 533 isCore = false;
15007
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15008
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15009 {
15010 2132 nxoffset[i] = 0;
15011 2132 nyoffset[i] = 0;
15012
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15013
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15014 2132 }
15015
15016 533 necktile=0;
15017 //TODO compatibility? -DD
15018 /*
15019 for(int32_t i=0; i<4; i++)
15020 {
15021 nx[i]=124;
15022 ny[i]=i*6+48;
15023 }*/
15024 533 bgsfx=-1;
15025 //no need for deadsfx
15026 533 }
15027
15028 515535 bool esGleeok::animate(int32_t index)
15029 {
15030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15031 // don't call removearmos() - it's a segment.
15032
15033 515535 dmisc5=vbound(dmisc5,1,255);
15034
15035
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15036 {
15037 402762 x = (xoffset+parent->x);
15038 402762 y = (yoffset+parent->y);
15039
15040
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15041 {
15042 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15043 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15044 1611048 }
15045 402762 }
15046
15047 // set up the head tiles
15048 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15049 /*
15050 if (dummy_bool[0]) //if this is a flame gleeok
15051 {
15052 headtile+=180;
15053 }
15054 */
15055 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15056 515535 flyingheadtile=dummy_int[3];
15057
15058 // set up the neck tiles
15059 515535 necktile=dummy_int[1];
15060
15061
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15062 {
15063 402833 necktile+=((clk&24)>>3);
15064 402833 }
15065
15066 /*
15067 else
15068 {
15069 necktile=145;
15070 }
15071 */
15072 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15073
15074
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15075 {
15076 case 0: // live head
15077 // set up the attached head tiles
15078 402762 tile=headtile;
15079
15080
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15081 {
15082 319820 tile+=((clk&24)>>3);
15083 /*
15084 if (dummy_bool[0]) {
15085 tile+=1561;
15086 }
15087 */
15088 319820 }
15089
15090 /*
15091 else
15092 {
15093 tile=146;
15094 }
15095 */
15096
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15097 {
15098
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15099
15100
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15101
15102
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15103 {
15104 292 dir^=1;
15105 292 }
15106
15107 92832 zfix tempx = x;
15108 92832 zfix tempy = y;
15109
15110 92832 sprite::move(step);
15111 92832 xoffset += (x-tempx);
15112 92832 yoffset += (y-tempy);
15113
15114
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15115 {
15116 3863 clk3^=1;
15117 3863 clk2=-4;
15118 3863 }
15119 else
15120 {
15121
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15122 {
15123 978 clk3=right;
15124 978 }
15125
15126
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15127 {
15128 961 clk3=left;
15129 961 }
15130
15131
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15132 {
15133 3713 clk3^=1; // x jig
15134 3713 }
15135 else
15136 {
15137
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15138 {
15139 851 clk3^=1; // x switch back
15140 851 }
15141
15142 85256 clk2=-4;
15143 }
15144 }
15145
15146 92832 zc_swap(dir,clk3);
15147 92832 tempx = x;
15148 92832 tempy = y;
15149 92832 sprite::move(step);
15150 92832 xoffset += (x-tempx);
15151 92832 yoffset += (y-tempy);
15152 92832 zc_swap(dir,clk3);
15153
15154
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15155 {
15156 278496 nxoffset[i] = (zc_oldrand()%3);
15157 278496 nyoffset[i] = (zc_oldrand()%3);
15158 278496 }
15159 92832 }
15160
15161 402762 break;
15162
15163 case 1: // flying head
15164
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15165
15166 {
15167 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15168 105482 }
15169
15170 112071 break;
15171
15172 // the following are messages sent from the main guy...
15173 case -1: // got chopped off
15174 {
15175 300 misc=1;
15176 300 superman=1;
15177 300 hxofs=xofs=0;
15178 300 hit_width=16;
15179 300 cs=8;
15180 300 clk=-24;
15181 300 clk2=40;
15182 300 dir=(zc_oldrand()&7)+8;
15183 300 step=8.0/9.0;
15184 }
15185 300 break;
15186
15187 case -2: // the big guy is dead
15188 402 return true;
15189 }
15190
15191
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15192 {
15193
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15194 {
15195 4791 FireBreath(true);
15196 4791 }
15197
15198 40125 --timer;
15199 40125 }
15200
15201 515133 return enemy::animate(index);
15202 515535 }
15203
15204 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15205 {
15206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15207 {
15208 int32_t wpnId = w->id;
15209
15210 if(dying)
15211 return 0;
15212
15213 switch(wpnId)
15214 {
15215 case wLitBomb:
15216 case wLitSBomb:
15217 case wBait:
15218 case wWhistle:
15219 case wFire:
15220 case wWind:
15221 case wSSparkle:
15222 case wFSparkle:
15223 case wPhantom:
15224 return 0;
15225
15226 case wHookshot:
15227 case wBrang:
15228 case wBeam:
15229 case wArrow:
15230 case wMagic:
15231 case wBomb:
15232 case wSBomb:
15233 sfx(WAV_CHINK,pan(x));
15234 break;
15235 default:
15236 break;
15237 }
15238
15239 return 1;
15240 }
15241 else
15242 {
15243 7080 int32_t ret = enemy::takehit(w,realweap);
15244
15245
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15246 5655 return -2; // force it to wait a frame before checking sword attacks again
15247
15248 1425 return ret;
15249 }
15250 7080 }
15251
15252 521456 void esGleeok::draw(BITMAP *dest)
15253 {
15254 521456 dmisc5=vbound(dmisc5,1,255);
15255
15256
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15257 {
15258 case 0: //neck
15259
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15260 {
15261
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15262 {
15263 1227318 mapscr* scr = get_scr(screen_spawned);
15264
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15265 {
15266
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15267 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15268 else
15269 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15270 978198 }
15271 else
15272 {
15273
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15274 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15275 else
15276 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15277 }
15278 1227318 }
15279 409106 }
15280
15281 409106 break;
15282
15283 case 1: //flying head
15284 112350 tile=flyingheadtile;
15285
15286
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15287 {
15288 82692 tile+=((clk&24)>>3);
15289 82692 break;
15290 }
15291 29658 }
15292 521456 }
15293
15294 521456 void esGleeok::draw2(BITMAP *dest)
15295 {
15296 521456 enemy::draw(dest);
15297 521456 }
15298
15299 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15300 190 {
15301
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15302 {
15303
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15304
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15305 190 }
15306 else { x = X; y = Y; }
15307 190 adjusted=false;
15308
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15309 //step=0.25;
15310 190 flycnt=dmisc1;
15311 190 flycnt2=dmisc2;
15312 190 loopcnt=0;
15313 190 clk4 = 0;
15314 190 clk5 = 0;
15315 190 clk6 = 0;
15316 190 clk7 = 0;
15317
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15319 {
15320
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15321 {
15322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15323 105 else dmisc29 = (84 / 3);
15324 105 }
15325 else
15326 {
15327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15328 85 else dmisc29 = (84 / 2);
15329 }
15330 190 }
15331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15332 {
15333
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15334 {
15335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15336 105 else dmisc30 = (84 / 3)*0.5;
15337 105 }
15338 else
15339 {
15340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15341 85 else dmisc30 = (84 / 2)*0.5;
15342 }
15343 190 }
15344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15345 {
15346
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15347 {
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15349 105 else dmisc31 = (84 / 3)*2;
15350 105 }
15351 else
15352 {
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15354 85 else dmisc31 = (84 / 2)*0.5;
15355 }
15356 190 }
15357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15358 {
15359
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15360 {
15361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15362 105 else dmisc32 = (84 / 3);
15363 105 }
15364 else
15365 {
15366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15367 85 else dmisc32 = (84 / 2)*0.25;
15368 }
15369 190 }
15370
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15371 190 }
15372
15373 161885 bool ePatra::animate(int32_t index)
15374 {
15375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15376
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15377 {
15378
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15379 {
15380 72 auto segment = (enemy*)guys.spr(i);
15381
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15382 72 segment->hp = -1000;
15383 72 }
15384
15385 1444 return Dead(index);
15386 }
15387
15388 160441 double basesize = 84;
15389
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15390 160441 double halfsize = basesize / 2;
15391 160441 double quartersize = halfsize / 2;
15392 160441 double twothirdsize = (basesize / 3)*2;
15393 160441 double onethirdsize = (basesize / 3);
15394
15395
15396
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15397 {
15398 36934 removearmos(x,y,ffcactivated);
15399 36934 }
15400
15401
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15402 {
15403
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15404
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15405
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15406 {
15407 1797 clk2=0;
15408
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15409 {
15410
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15411 932 --loopcnt;
15412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15413 {
15414
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15415 {
15416
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15417 356 else loopcnt=dmisc7;
15418 356 }
15419 865 }
15420 else if (loopcnt == -1) loopcnt=dmisc7;
15421 else ++loopcnt;
15422
15423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15424 1797 }
15425 else
15426 {
15427 loopcnt = 0;
15428 misc = 1;
15429 }
15430 1797 }
15431 160441 }
15432
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15433
15434
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15435 {
15436 if (dmisc5 == 1 || dmisc5 == 3)
15437 {
15438 if (get_qr(qr_NEWENEMYTILES))
15439 {
15440 if (clk7 <= 0 || clk6 != -16) ++clk6;
15441 if (clk6 == 0) o_tile=d->e_tile;
15442 else
15443 {
15444 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15445 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15446 }
15447 }
15448 else clk6 = 0;
15449 }
15450 }
15451
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15452
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15453
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15454
15455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15456
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15457
15458
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15459 {
15460 //outside ring
15461
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15462 {
15463
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15464 {
15465 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15466 1152 enemy *s = ((enemy*)guys.spr(i));
15467 1152 s->setParent(this);
15468 1152 }
15469 else
15470 {
15471 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15472 192 enemy *s = ((enemy*)guys.spr(i));
15473 192 s->setParent(this);
15474 }
15475
15476 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15477 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15478 1344 }
15479
15480
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15481 {
15482
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15483 {
15484 2889 guys.swap(j,j+1);
15485 2889 }
15486
15487
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15488 764 }
15489 else
15490 {
15491 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15492
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15493
15494
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15495 {
15496 //maybe playing_field_offset here?
15497
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15498 {
15499
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15500
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15501 237330 }
15502 else
15503 {
15504 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15505 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15506 }
15507
15508 447583 temp_x=guys.spr(i)->x;
15509 447583 temp_y=guys.spr(i)->y;
15510 447583 }
15511 else //Oval
15512 {
15513 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15514 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15515
15516
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15517 {
15518 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15519
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15520 121041 }
15521 else
15522 {
15523 90996 guys.spr(i)->x = circle_x;
15524 90996 guys.spr(i)->y = circle_y;
15525 }
15526
15527 212037 temp_x=circle_x;
15528 212037 temp_y=circle_y;
15529 }
15530
15531 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15532 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15533
15534
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15535 {
15536 83117 guys.spr(i)->dir=l_down;
15537 83117 }
15538
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15539 {
15540 83568 guys.spr(i)->dir=left;
15541 83568 }
15542
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15543 {
15544 82454 guys.spr(i)->dir=l_up;
15545 82454 }
15546
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15547 {
15548 82188 guys.spr(i)->dir=up;
15549 82188 }
15550
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15551 {
15552 81600 guys.spr(i)->dir=r_up;
15553 81600 }
15554
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15555 {
15556 81993 guys.spr(i)->dir=right;
15557 81993 }
15558
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15559 {
15560 81699 guys.spr(i)->dir=r_down;
15561 81699 }
15562 else
15563 {
15564 83001 guys.spr(i)->dir=down;
15565 }
15566
15567 659620 guys.spr(i)->x += x;
15568 659620 guys.spr(i)->y += y;
15569 }
15570 660384 }
15571
15572
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15573 {
15574 32331 int timeneeded = 48;
15575 32331 int patbreath = (zc_oldrand()%50+50);
15576
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15577
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15578 {
15579 timeneeded = 48 + patbreath;
15580 }
15581
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15582 {
15583 timeneeded = 48 + 96;
15584 }
15585
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15586
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15587
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15588 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15589 249 && (clk6 >= 0) //if not in the middle of firing...
15590 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15591
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15592 {
15593
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15594 {
15595 case patratSTREAM:
15596 {
15597 clk7 = 97;
15598 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15599 else clk6 = 0;
15600 break;
15601 }
15602 case patratBREATH:
15603 {
15604 clk7 = patbreath;
15605 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15606 else clk6 = 0;
15607 break;
15608 }
15609 default:
15610 {
15611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15612 {
15613 clk6 = -48;
15614 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15615 }
15616 else
15617 {
15618 249 clk6 = 0;
15619
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15620 249 FirePatraWeapon();
15621 }
15622 249 break;
15623 }
15624 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15625 249 }
15626
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15627 {
15628 switch(dmisc28)
15629 {
15630 case patratSTREAM:
15631 {
15632 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15633 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15634 break;
15635 }
15636 case patratBREATH:
15637 {
15638 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15639 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15640 break;
15641 }
15642 default:
15643 {
15644 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15645 {
15646 FirePatraWeapon();
15647 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15648 }
15649 break;
15650 }
15651 }
15652 }
15653 32331 }
15654
15655 160441 int randattempts = 0;
15656 160441 int randeye = 0;
15657
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15658 {
15659 46240 do
15660 {
15661
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15662 46240 randeye += (index + flycnt + 1);
15663 46240 ++randattempts;
15664
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15665 46240 }
15666 160441 bool dofire = false;
15667
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15668 {
15669 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15670 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15671 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15672 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15673 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15674 {
15675 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15676 {
15677 if (clk5 >= dmisc19)
15678 {
15679 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15680 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15681 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15682 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15683 || dmisc18 == -1)
15684 dofire = true;
15685 }
15686 }
15687 }
15688 }
15689
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15690 {
15691
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15692 {
15693
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15694 {
15695 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15696
15697
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15698 {
15699
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15700 {
15701
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15702 {
15703 // Center eye shoots projectiles; make room for its firing tiles
15704 case 1:
15705 case 3:
15706 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15707 144 break;
15708
15709 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15710 default:
15711 case 2:
15712 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15713 168 break;
15714 }
15715 312 }
15716 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15717 312 }
15718 else
15719 {
15720 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15721 }
15722
15723 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15724
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15725 312 }
15726
15727
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15728 {
15729 263816 ((enemy*)guys.spr(i))->superman=true;
15730 263816 }
15731 else
15732 {
15733 70613 ((enemy*)guys.spr(i))->superman=false;
15734 }
15735
15736
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15737 {
15738
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15739 {
15740 269 guys.swap(j,j+1);
15741 269 }
15742
15743
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15744 145 }
15745 else
15746 {
15747 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15748
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15749
15750
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15751 {
15752
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15753 {
15754
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15755
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15756 168378 }
15757 else
15758 {
15759 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15760 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15761 }
15762
15763 327025 temp_x=guys.spr(i)->x;
15764 327025 temp_y=guys.spr(i)->y;
15765 327025 }
15766 else
15767 {
15768 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15769 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15770
15771
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15772 {
15773 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15774
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15775 3965 }
15776 else
15777 {
15778 3294 guys.spr(i)->x = circle_x;
15779 3294 guys.spr(i)->y = circle_y;
15780 }
15781
15782 7259 temp_x=circle_x;
15783 7259 temp_y=circle_y;
15784 }
15785
15786 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15787 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15788
15789
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15790 {
15791 41746 guys.spr(i)->dir=l_down;
15792 41746 }
15793
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15794 {
15795 41734 guys.spr(i)->dir=left;
15796 41734 }
15797
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15798 {
15799 41742 guys.spr(i)->dir=l_up;
15800 41742 }
15801
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15802 {
15803 41758 guys.spr(i)->dir=up;
15804 41758 }
15805
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15806 {
15807 41830 guys.spr(i)->dir=r_up;
15808 41830 }
15809
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15810 {
15811 41824 guys.spr(i)->dir=right;
15812 41824 }
15813
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15814 {
15815 41852 guys.spr(i)->dir=r_down;
15816 41852 }
15817 else
15818 {
15819 41798 guys.spr(i)->dir=down;
15820 }
15821
15822 334284 guys.spr(i)->x += x;
15823 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15824
15825
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15826 {
15827 /*
15828 if(!(zc_oldrand()&127))
15829 {
15830 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15831 sfx(wpnsfx(wpn),pan(x));
15832 }
15833 */
15834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15835 {
15836 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15837 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15838 {
15839 if (dmisc5 == 3)
15840 {
15841 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15842 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15843 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15844 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15845 }
15846 else
15847 {
15848 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15850 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15851 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15852 }
15853 }
15854 else
15855 {
15856 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15857 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15858 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15859 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15860 }
15861 }
15862
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15863
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15864
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15865 {
15866
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15867 {
15868 case 4: //Single one rapidfires
15869 {
15870 if (dofire && i == randeye)
15871 {
15872 ((esPatra*)guys.spr(i))->clk5 = -16;
15873 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15874 ((esPatra*)guys.spr(i))->clk4 = 96;
15875 clk5 = -3;
15876 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15877 }
15878 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15879 {
15880 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15881 sfx(wpnsfx(wpn),pan(x));
15882 }
15883 break;
15884 }
15885 case 3: //Ring
15886 {
15887 if (dofire)
15888 {
15889 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15890 {
15891 ((esPatra*)guys.spr(i))->clk5 = -48;
15892 clk5 = -48;
15893 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15894 }
15895 else
15896 {
15897 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15898 sfx(wpnsfx(wpn),pan(x));
15899 int32_t m=Ewpns.Count()-1;
15900 weapon *ew = (weapon*)(Ewpns.spr(m));
15901
15902 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15903 ((esPatra*)guys.spr(i))->clk5 = 0;
15904 clk5 = 0;
15905 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15906 }
15907 }
15908 if (((esPatra*)guys.spr(i))->clk5 == -16)
15909 {
15910 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15911 sfx(wpnsfx(wpn),pan(x));
15912 int32_t m=Ewpns.Count()-1;
15913 weapon *ew = (weapon*)(Ewpns.spr(m));
15914
15915 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15916 }
15917 break;
15918 }
15919 case 2: //one after another
15920 {
15921 if (dofire)
15922 {
15923 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15924 clk5 = -48 - (12*flycnt2);
15925 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15926 }
15927 if (((esPatra*)guys.spr(i))->clk5 == -16)
15928 {
15929 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15930 sfx(wpnsfx(wpn),pan(x));
15931 }
15932 break;
15933 }
15934 case 1: //random one eye
15935 {
15936 if (dofire && i == randeye)
15937 {
15938 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15939 {
15940 ((esPatra*)guys.spr(i))->clk5 = -48;
15941 clk5 = -48;
15942 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15943 }
15944 else
15945 {
15946 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15947 sfx(wpnsfx(wpn),pan(x));
15948 ((esPatra*)guys.spr(i))->clk5 = 0;
15949 clk5 = 0;
15950 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15951 }
15952 }
15953 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15954 {
15955 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15956 sfx(wpnsfx(wpn),pan(x));
15957 }
15958 break;
15959 }
15960 default: //old behavior, all eyes can fire any time
15961 {
15962
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15963
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15964
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15965 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15966 {
15967
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15968 {
15969 ((esPatra*)guys.spr(i))->clk5 = -48;
15970 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15971 }
15972 else
15973 {
15974 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15975 1155 sfx(wpnsfx(wpn),pan(x));
15976 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15977
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15978 }
15979 1155 }
15980
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15981 {
15982 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15983 sfx(wpnsfx(wpn),pan(x));
15984 }
15985 145268 break;
15986 }
15987 }
15988 145268 }
15989 145268 }
15990
15991 }
15992 334429 }
15993 46240 }
15994
15995 160441 adjusted=true;
15996 160441 return enemy::animate(index);
15997 161885 }
15998
15999 249 void ePatra::FirePatraWeapon()
16000 { //.707
16001 249 int32_t xoff = 0;
16002 249 int32_t yoff = 0;
16003
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16004 {
16005 xoff += hxofs;
16006 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
16007 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16008 else
16009 xoff += (hit_width / 2) - 8;
16010 }
16011
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16012 {
16013 yoff += hyofs;
16014 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16015 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16016 else
16017 yoff += (hit_height / 2) - 8;
16018 }
16019 249 sfx(wpnsfx(wpn),pan(x));
16020 // TODO(crash): check that .add succeeds.
16021
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16022 {
16023 case patrat8SHOT: //Fire Wizzrobe
16024 case patrat4SHOTDIAG:
16025 case patrat4SHOTRAND:
16026 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16027 {
16028 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16029 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16030 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16031 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16032
16033 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16034 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16036 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16037
16038 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16040 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16041 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16042
16043 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16044 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16046 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16047
16048 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16049 }
16050
16051 [[fallthrough]];
16052 case patrat4SHOTCARD: //Stalfos 3
16053 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16054 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16055 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16056 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16057 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16058 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16059 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16060 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16061 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16062 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16063 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16064 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16065 break;
16066
16067 default:
16068 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16069
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16070 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16071
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16072
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16073 {
16074 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16075 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16076 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16077 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16078 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16079 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16081 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16082 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16083 {
16084 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16085 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16086 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16087 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16088 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16089 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16090 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16091 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16092 }
16093 }
16094 249 break;
16095
16096 }
16097 249 sfx(wpnsfx(wpn),pan(x));
16098 //+0.46364761
16099 //11.80
16100 249 }
16101
16102 324242 void ePatra::draw(BITMAP *dest)
16103 {
16104 324242 tile=o_tile;
16105 324242 update_enemy_frame();
16106 324242 enemy::draw(dest);
16107 324242 }
16108
16109 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16110 {
16111 int32_t ret = enemy::defend(wpnId, power, edef);
16112
16113 if(ret < 0 && (flycnt||flycnt2))
16114 return 0;
16115
16116 return ret;
16117 }
16118
16119 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16120 {
16121 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16122
16123
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16124 1281 return 0;
16125
16126 452 return ret;
16127 1733 }
16128
16129 190 void ePatra::init_size_flags() {
16130 190 SIZEflags = d->SIZEflags;
16131
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16132
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16133 // al_trace("Enemy txsz:%i\n", txsz);
16134
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16135
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16137
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16141
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16142
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16143 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16145
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16147 {
16148 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16149 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16150 }
16151
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16152
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16153
16154
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16155
16156 190 }
16157
16158 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16159 1656 {
16160 //cs=8;
16161
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16162 1656 item_set=0;
16163 1656 misc=clk;
16164 1656 clk4 = 0;
16165 1656 clk5 = 0;
16166 1656 clk = -((misc*21)>>1)-1;
16167
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16168 1656 hit_width=12;
16169 1656 hit_height=12;
16170 1656 hxofs=2;
16171 1656 hyofs=2;
16172 1656 extend = 0;
16173 1656 txsz = 1;
16174 1656 tysz = 1;
16175 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16176 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16177 int32_t prntSIZEflags = prntenemy->SIZEflags;
16178 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16179 // al_trace("Enemy txsz:%i\n", txsz);
16180 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16181 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16182 else
16183 hxsz=12;
16184 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16185 else
16186 hysz=12;
16187 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16188 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16189 else
16190 hxofs=2;
16191 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16192 else hyofs=2;
16193 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16194 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16195 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16196 {
16197 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16198 }
16199
16200 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16201 */
16202 1656 mainguy=count_enemy=false;
16203 1656 bgsfx=-1;
16204 //o_tile=0;
16205
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16206 1656 deadsfx = WAV_EDEAD;
16207 1656 hitsfx = WAV_EHIT;
16208 1656 isCore = false;
16209 1656 }
16210
16211 1010584 bool esPatra::animate(int32_t index)
16212 {
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16214
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16215 15160 return Dead(index);
16216
16217 995424 return enemy::animate(index);
16218 1010584 }
16219
16220 2028196 void esPatra::draw(BITMAP *dest)
16221 {
16222
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16223 {
16224 1721294 tile = o_tile+(clk&3);
16225
16226
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16227 {
16228 case up: //u
16229 214278 flip=0;
16230 214278 break;
16231
16232 case down: //d
16233 217924 flip=0;
16234 217924 tile+=4;
16235 217924 break;
16236
16237 case left: //l
16238 215346 flip=0;
16239 215346 tile+=8;
16240 215346 break;
16241
16242 case right: //r
16243 215726 flip=0;
16244 215726 tile+=12;
16245 215726 break;
16246
16247 case l_up: //ul
16248 213062 flip=0;
16249 213062 tile+=20;
16250 213062 break;
16251
16252 case r_up: //ur
16253 214350 flip=0;
16254 214350 tile+=24;
16255 214350 break;
16256
16257 case l_down: //dl
16258 215734 flip=0;
16259 215734 tile+=28;
16260 215734 break;
16261
16262 case r_down: //dr
16263 214874 flip=0;
16264 214874 tile+=32;
16265 214874 break;
16266 }
16267 1721294 }
16268 else
16269 {
16270 306902 tile = o_tile+((clk&2)>>1);
16271 }
16272
16273
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16274 1913340 enemy::draw(dest);
16275 2028196 }
16276
16277
16278 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16279 102 {
16280 102 adjusted=false;
16281
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16282
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16283 102 clk4 = 0;
16284 102 clk5 = 0;
16285 //flycnt=6; flycnt2=0;
16286 102 flycnt=dmisc1;
16287 102 flycnt2=0; // PatraBS doesn't have inner rings!
16288 102 loopcnt=0;
16289
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16291
16292 //nets+4480;
16293 102 }
16294
16295 35963 bool ePatraBS::animate(int32_t index)
16296 {
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16298
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16299 240 return Dead(index);
16300
16301
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16302 {
16303 4018 removearmos(x,y,ffcactivated);
16304 4018 }
16305
16306 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16307
16308
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16309 {
16310 336 clk2=0;
16311
16312
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16313 177 --loopcnt;
16314 else
16315 {
16316
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16317 84 loopcnt=dmisc7;
16318 }
16319
16320 336 ++misc;
16321 336 }
16322
16323 // double size=1;;
16324
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16325 {
16326
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16327 {
16328 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16329
16330
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16331 {
16332 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16333 612 }
16334 else
16335 {
16336 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16337 }
16338
16339 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16340 612 }
16341
16342
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16343 {
16344
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16345 {
16346 131 guys.swap(j,j+1);
16347 131 }
16348
16349 104 --flycnt;
16350 104 }
16351 else
16352 {
16353 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16354
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16355 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16356 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16357
16358
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16359 {
16360 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16361
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16362 77643 }
16363 else
16364 {
16365 75725 guys.spr(i)->x = temp_x;
16366 75725 guys.spr(i)->y = temp_y;
16367 }
16368
16369 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16370 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16371
16372
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16373 {
16374 18812 guys.spr(i)->dir=l_down;
16375 18812 }
16376
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16377 {
16378 18839 guys.spr(i)->dir=left;
16379 18839 }
16380
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16381 {
16382 18802 guys.spr(i)->dir=l_up;
16383 18802 }
16384
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16385 {
16386 20143 guys.spr(i)->dir=up;
16387 20143 }
16388
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16389 {
16390 18517 guys.spr(i)->dir=r_up;
16391 18517 }
16392
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16393 {
16394 18779 guys.spr(i)->dir=right;
16395 18779 }
16396
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16397 {
16398 18992 guys.spr(i)->dir=r_down;
16399 18992 }
16400 else
16401 {
16402 20484 guys.spr(i)->dir=down;
16403 }
16404
16405 153368 guys.spr(i)->x += x;
16406 153368 guys.spr(i)->y += y;
16407 }
16408 153472 }
16409
16410 35723 adjusted=true;
16411 35723 return enemy::animate(index);
16412 35963 }
16413
16414 72874 void ePatraBS::draw(BITMAP *dest)
16415 {
16416 72874 tile=o_tile;
16417
16418
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16419 {
16420 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16421 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16422
16423
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16424 {
16425 19146 lookat=l_down;
16426 19146 }
16427
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16428 {
16429 18298 lookat=down;
16430 18298 }
16431
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16432 {
16433 13624 lookat=r_down;
16434 13624 }
16435
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16436 {
16437 7492 lookat=right;
16438 7492 }
16439
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16440 {
16441 1170 lookat=r_up;
16442 1170 }
16443
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16444 {
16445 964 lookat=up;
16446 964 }
16447
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16448 {
16449 1700 lookat=l_up;
16450 1700 }
16451 else
16452 {
16453 10480 lookat=left;
16454 }
16455
16456
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16457 {
16458 case up: //u
16459 964 flip=0;
16460 964 break;
16461
16462 case down: //d
16463 18298 flip=0;
16464 18298 tile+=8;
16465 18298 break;
16466
16467 case left: //l
16468 10480 flip=0;
16469 10480 tile+=40;
16470 10480 break;
16471
16472 case right: //r
16473 7492 flip=0;
16474 7492 tile+=48;
16475 7492 break;
16476
16477 case l_up: //ul
16478 1700 flip=0;
16479 1700 tile+=80;
16480 1700 break;
16481
16482 case r_up: //ur
16483 1170 flip=0;
16484 1170 tile+=88;
16485 1170 break;
16486
16487 case l_down: //dl
16488 19146 flip=0;
16489 19146 tile+=120;
16490 19146 break;
16491
16492 case r_down: //dr
16493 13624 flip=0;
16494 13624 tile+=128;
16495 13624 break;
16496 }
16497
16498 72874 tile+=(2*(clk&3));
16499 72874 xofs-=8;
16500 72874 yofs-=8;
16501 72874 drawblock(dest,15);
16502 72874 xofs+=8;
16503 72874 yofs+=8;
16504 72874 }
16505 else
16506 {
16507 flip=(clk&1);
16508 xofs-=8;
16509 yofs-=8;
16510 enemy::draw(dest);
16511 xofs+=16;
16512 enemy::draw(dest);
16513 yofs+=16;
16514 enemy::draw(dest);
16515 xofs-=16;
16516 enemy::draw(dest);
16517 xofs+=8;
16518 yofs-=8;
16519 }
16520 72874 }
16521
16522 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16523 {
16524 int32_t ret = enemy::defend(wpnId, power, edef);
16525
16526 if(ret < 0 && (flycnt||flycnt2))
16527 return 0;
16528
16529 return ret;
16530 }
16531
16532 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16533 {
16534 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16535
16536
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16537 81 return 0;
16538
16539 61 return ret;
16540 142 }
16541
16542 102 void ePatraBS::init_size_flags()
16543 {
16544 102 SIZEflags = d->SIZEflags;
16545
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16546 // al_trace("Enemy txsz:%i\n", txsz);
16547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16549 102 else hit_width = 32;
16550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16553 102 else hxofs = -8;
16554
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16555 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16556
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16557
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16558 {
16559 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16560 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16561 }
16562
16563
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16564 102 }
16565
16566 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16567 612 {
16568 //cs=csBOSS;
16569
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16570 612 item_set=0;
16571 612 misc=clk;
16572 612 clk = -((misc*21)>>1)-1;
16573 612 clk4 = 0;
16574 612 clk5 = 0;
16575
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16576 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16577
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16578 // al_trace("Enemy txsz:%i\n", txsz);
16579
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16581 612 else hit_width=16;
16582
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16583 612 else hit_height=16;
16584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16585
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16587 612 else hyofs=2;
16588 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16589
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16591 {
16592 yofs = (int32_t)prntenemy->yofs;
16593 }
16594
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16595
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16596
16597 612 bgsfx=-1;
16598 612 mainguy=count_enemy=false;
16599 612 deadsfx = WAV_EDEAD;
16600 612 hitsfx = WAV_EHIT;
16601
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16602 612 isCore = false;
16603 612 }
16604
16605 155090 bool esPatraBS::animate(int32_t index)
16606 {
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16608
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16609 1552 return Dead(index);
16610
16611 153538 return enemy::animate(index);
16612 155090 }
16613
16614 315868 void esPatraBS::draw(BITMAP *dest)
16615 {
16616 315868 tile=o_tile;
16617
16618
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16619 {
16620
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16621 {
16622 case up: //u
16623 41612 flip=0;
16624 41612 break;
16625
16626 case down: //d
16627 42622 flip=0;
16628 42622 tile+=4;
16629 42622 break;
16630
16631 case left: //l
16632 37916 flip=0;
16633 37916 tile+=8;
16634 37916 break;
16635
16636 case right: //r
16637 38458 flip=0;
16638 38458 tile+=12;
16639 38458 break;
16640
16641 case l_up: //ul
16642 38564 flip=0;
16643 38564 tile+=20;
16644 38564 break;
16645
16646 case r_up: //ur
16647 38568 flip=0;
16648 38568 tile+=24;
16649 38568 break;
16650
16651 case l_down: //dl
16652 38662 flip=0;
16653 38662 tile+=28;
16654 38662 break;
16655
16656 case r_down: //dr
16657 39466 flip=0;
16658 39466 tile+=32;
16659 39466 break;
16660 }
16661
16662 315868 tile += ((clk&6)>>1);
16663 315868 }
16664 else
16665 {
16666 tile += (clk&4)?1:0;
16667 }
16668
16669
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16670 283752 enemy::draw(dest);
16671 315868 }
16672
16673 257618 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16674 {
16675
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106870 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257618 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16676
4/8
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257618 times.
✗ Branch 7 not taken.
257618 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16677
1/2
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
257618 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16678 257618 }
16679
16680 74710 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16681 {
16682 // Kludge
16683
4/8
✓ Branch 0 taken 74710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74710 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74710 times.
✗ Branch 7 not taken.
74710 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16684 74710 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74710 times.
74710 delete w;
16686 74710 return ret;
16687 }
16688
16689 9214 void enemy_scored(int32_t index)
16690 {
16691 9214 ((enemy*)guys.spr(index))->scored=true;
16692 9214 }
16693
16694 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16695 {
16696
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16697
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16698 765 g->y += 1;
16699
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16700 {
16701 4 g->o_tile = parentscr->guytile;
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16703 4 g->flags &= ~guy_invisible;
16704 4 g->cs = parentscr->guycs;
16705 4 }
16706 2191 guys.add(g);
16707 2191 }
16708
16709 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16710 {
16711
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16712 23701 items.add(i);
16713 23701 }
16714
16715 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16716 {
16717
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16718 150 items.add(i);
16719 150 }
16720
16721 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16722 {
16723
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16724 3 items.add(i);
16725 3 }
16726
16727 19326 void add_item_for_screen(int32_t screen, item* item)
16728 {
16729 19326 item->screen_spawned = screen;
16730 19326 items.add(item);
16731 19326 }
16732
16733 96 void kill_em_all()
16734 {
16735
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16736 {
16737 353 enemy *e = ((enemy*)guys.spr(i));
16738
16739
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16740
16741 323 e->kickbucket();
16742 323 }
16743 96 }
16744
16745 bool can_kill_em_all()
16746 {
16747 for(int32_t i=0; i<guys.Count(); i++)
16748 {
16749 enemy *e = ((enemy*)guys.spr(i));
16750
16751 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16752 if(e->superman) continue;
16753 return true;
16754 }
16755 return false;
16756 }
16757
16758 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16759 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16760 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16761 {
16762 for(int32_t i=0; i<guys.Count(); i++)
16763 {
16764 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16765 {
16766 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16767 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16768 {
16769 return i;
16770 }
16771 }
16772 }
16773
16774 return -1;
16775 }
16776
16777 13157767 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16778 {
16779
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13141256 times.
✓ Branch 2 taken 33818802 times.
✓ Branch 3 taken 13126788 times.
46945590 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16780 {
16781
2/2
✓ Branch 0 taken 30979 times.
✓ Branch 1 taken 33787823 times.
33818802 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16782 {
16783 30979 return i;
16784 }
16785 33787823 }
16786
16787 13126788 return -1;
16788 13157767 }
16789
16790 // For Hero's hit detection. Count them if they are dying.
16791 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16792 {
16793 52508 enemy *e = (enemy*)guys.spr(index);
16794
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16795 28055 return -1;
16796
16797 24453 bool d = e->dying;
16798 24453 int32_t hc = e->hclk;
16799 24453 e->dying = false;
16800 24453 e->hclk = 0;
16801 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16802 24453 e->dying = d;
16803 24453 e->hclk = hc;
16804
16805
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16806 52508 }
16807
16808 14675165 bool hasMainGuy(int screen)
16809 {
16810
2/2
✓ Branch 0 taken 15979810 times.
✓ Branch 1 taken 5951056 times.
21930866 for(int32_t i=0; i<guys.Count(); i++)
16811 {
16812 15979810 enemy* e = (enemy*)guys.spr(i);
16813
4/4
✓ Branch 0 taken 15516726 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 8724109 times.
✓ Branch 3 taken 6792617 times.
15979810 if (e->screen_spawned == screen && e->mainguy)
16814 {
16815 8724109 return true;
16816 }
16817 7255701 }
16818
16819 5951056 return false;
16820 14675165 }
16821
16822 138 void EatHero(int32_t index)
16823 {
16824 138 ((eStalfos*)guys.spr(index))->eathero();
16825 138 }
16826
16827 9 void GrabHero(int32_t index)
16828 {
16829 9 ((eWallM*)guys.spr(index))->grabhero();
16830 9 }
16831
16832 1338 bool CarryHero()
16833 {
16834
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16835 {
16836
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16837 {
16838
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16839 {
16840 1338 Hero.x=guys.spr(i)->x;
16841 1338 Hero.y=guys.spr(i)->y;
16842 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16843 }
16844 505 }
16845
16846 // Like Likes currently can't carry Hero.
16847 /*
16848 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16849 {
16850 if(((eLikeLike*)guys.spr(i))->hashero)
16851 {
16852 Hero.x=guys.spr(i)->x;
16853 Hero.y=guys.spr(i)->y;
16854 return (true);
16855 }
16856 }*/
16857 2595 }
16858
16859 return false;
16860 1338 }
16861
16862 // Move item with guy
16863 void movefairy(zfix &x,zfix &y,int32_t misc)
16864 {
16865 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16866
16867 if(i!=-1)
16868 {
16869 x = guys.spr(i)->x;
16870 y = guys.spr(i)->y;
16871 }
16872 }
16873
16874 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16875 void movefairy2(zfix x,zfix y,int32_t misc)
16876 {
16877 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16878
16879 if(i!=-1)
16880 {
16881 guys.spr(i)->x = x;
16882 guys.spr(i)->y = y;
16883 }
16884 }// Move item with guy
16885
16886 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16887 {
16888 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16889
16890
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16891 {
16892 60788 x = fairy->x;
16893 60788 y = fairy->y;
16894 60788 }
16895 60788 }
16896
16897 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16898 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16899 {
16900 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16901
16902
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16903 {
16904 404 fairy->x = x;
16905 404 fairy->y = y;
16906 404 }
16907 404 }
16908
16909 void killfairy(int32_t misc)
16910 {
16911 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16912 guys.del(i);
16913 }
16914
16915 219 int32_t getGuyIndex(const int32_t eid)
16916 {
16917
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16918 {
16919
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16920 219 return i;
16921 609 }
16922
16923 return -1;
16924 219 }
16925
16926 219 void killfairynew(item const &itemfairy)
16927 {
16928 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16929
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16930 219 }
16931
16932 //Should probably change this to return an 'enemy*', null on failure -Em
16933 21822 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16934 {
16935 21822 return addenemy_z(screen,x,y,0,id,clk);
16936 }
16937
16938 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16939 {
16940 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16941 }
16942
16943 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16944 {
16945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16946
16947 1997 int32_t ret = 0;
16948 1997 sprite *e=NULL;
16949
16950
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16951 {
16952 //Fixme: possible enemy memory leak. (minor)
16953 case eeWALK:
16954
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16955 110 break;
16956
16957 case eeLEV:
16958 e = new eLeever((zfix)x,(zfix)y,id,clk);
16959 break;
16960
16961 case eeTEK:
16962 e = new eTektite((zfix)x,(zfix)y,id,clk);
16963 break;
16964
16965 case eePEAHAT:
16966 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16967 break;
16968
16969 case eeZORA:
16970 e = new eZora((zfix)x,(zfix)y,id,clk);
16971 break;
16972
16973 case eeGHINI:
16974 e = new eGhini((zfix)x,(zfix)y,id,clk);
16975 break;
16976
16977 case eeKEESE:
16978
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16979 1865 break;
16980
16981 case eeWIZZ:
16982
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16983 15 break;
16984
16985 case eePROJECTILE:
16986 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16987 break;
16988
16989 case eeWALLM:
16990 e = new eWallM((zfix)x,(zfix)y,id,clk);
16991 break;
16992
16993 case eeAQUA:
16994 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16995 break;
16996
16997 case eeMOLD:
16998 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16999 break;
17000
17001 case eeMANHAN:
17002
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17003 1 break;
17004
17005 case eeGLEEOK:
17006 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17007 break;
17008
17009 case eeGHOMA:
17010 e = new eGohma((zfix)x,(zfix)y,id,clk);
17011 break;
17012
17013 case eeLANM:
17014 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17015 break;
17016
17017 case eeGANON:
17018 e = new eGanon((zfix)x,(zfix)y,id,clk);
17019 break;
17020
17021 case eeFAIRY:
17022 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17023 break;
17024
17025 case eeFIRE:
17026
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17027 2 break;
17028
17029 case eeOTHER:
17030 e = new eOther((zfix)x,(zfix)y,id,clk);
17031 break;
17032
17033
17034 case eeSCRIPT01:
17035 case eeSCRIPT02:
17036 case eeSCRIPT03:
17037 case eeSCRIPT04:
17038 case eeSCRIPT05:
17039 case eeSCRIPT06:
17040 case eeSCRIPT07:
17041 case eeSCRIPT08:
17042 case eeSCRIPT09:
17043 case eeSCRIPT10:
17044 case eeSCRIPT11:
17045 case eeSCRIPT12:
17046 case eeSCRIPT13:
17047 case eeSCRIPT14:
17048 case eeSCRIPT15:
17049 case eeSCRIPT16:
17050 case eeSCRIPT17:
17051 case eeSCRIPT18:
17052 case eeSCRIPT19:
17053 case eeSCRIPT20:
17054 {
17055 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17056 {
17057 e = new eScript((zfix)x,(zfix)y,id,clk);
17058 break;
17059 }
17060 else return 0;
17061 }
17062
17063 case eeFFRIENDLY01:
17064 case eeFFRIENDLY02:
17065 case eeFFRIENDLY03:
17066 case eeFFRIENDLY04:
17067 case eeFFRIENDLY05:
17068 case eeFFRIENDLY06:
17069 case eeFFRIENDLY07:
17070 case eeFFRIENDLY08:
17071 case eeFFRIENDLY09:
17072 case eeFFRIENDLY10:
17073 {
17074 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17075 {
17076 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17077 }
17078 else return 0;
17079
17080 }
17081
17082 case eeSPINTILE:
17083 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17084 break;
17085
17086 // and these enemies use the misc10/misc2 value
17087 case eeROCK:
17088 {
17089 switch(guysbuf[id&0xFFF].attributes[9])
17090 {
17091 case 1:
17092 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17093 break;
17094
17095 case 0:
17096 default:
17097 e = new eRock((zfix)x,(zfix)y,id,clk);
17098 break;
17099 }
17100
17101 break;
17102 }
17103
17104 case eeTRAP:
17105 {
17106 switch(guysbuf[id&0xFFF].attributes[1])
17107 {
17108 case 1:
17109 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17110 break;
17111
17112 case 0:
17113 default:
17114 e = new eTrap((zfix)x,(zfix)y,id,clk);
17115 break;
17116 }
17117
17118 break;
17119 }
17120
17121 case eeDONGO:
17122 {
17123 switch(guysbuf[id&0xFFF].attributes[9])
17124 {
17125 case 1:
17126 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17127 break;
17128
17129 case 0:
17130 default:
17131 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17132 break;
17133 }
17134
17135 break;
17136 }
17137
17138 case eeDIG:
17139 {
17140
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17141 {
17142 case 1:
17143 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17144 break;
17145
17146 4 case 0:
17147 default:
17148
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17149 4 break;
17150 }
17151
17152 4 break;
17153 }
17154
17155 case eePATRA:
17156 {
17157 switch(guysbuf[id&0xFFF].attributes[9])
17158 {
17159 case 1:
17160 if (get_qr(qr_HARDCODED_BS_PATRA))
17161 {
17162 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17163 break;
17164 }
17165 [[fallthrough]];
17166 case 0:
17167 default:
17168 e = new ePatra((zfix)x,(zfix)y,id,clk);
17169 break;
17170 }
17171
17172 break;
17173 }
17174
17175 case eeGUY:
17176 {
17177 switch(guysbuf[id&0xFFF].attributes[9])
17178 {
17179 case 1:
17180 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17181 break;
17182
17183 case 0:
17184 default:
17185 e = new eNPC((zfix)x,(zfix)y,id,clk);
17186 break;
17187 }
17188
17189 break;
17190 }
17191
17192 case eeNONE:
17193 if(guysbuf[id&0xFFF].attributes[9] ==1)
17194 {
17195 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17196 break;
17197 break;
17198 }
17199 [[fallthrough]];
17200 default:
17201
17202 return 0;
17203 }
17204
17205 1997 ret++; // Made one enemy.
17206
17207
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17208 {
17209 7 e->z = (zfix)z;
17210 7 }
17211
17212
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17213 1997 e->setParent(parent);
17214
17215
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17216 {
17217 return 0;
17218 }
17219
17220 // add segments of segmented enemies
17221 1997 int32_t c=0;
17222
17223
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17224 {
17225 case eeMOLD:
17226 {
17227 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17228 id &= 0xFFF;
17229
17230 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17231 {
17232 //christ this is messy -DD
17233 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17234
17235 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17236 {
17237 al_trace("Moldorm segment %d could not be created!\n",i+1);
17238
17239 for(int32_t j=0; j<i+1; j++)
17240 guys.del(guys.Count()-1);
17241
17242 return 0;
17243 }
17244
17245 if(i>0)
17246 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17247
17248 ret++;
17249 }
17250
17251 break;
17252 }
17253
17254 case eeLANM:
17255 {
17256 id &= 0xFFF;
17257 int32_t shft = guysbuf[id].attributes[1];
17258 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17259
17260 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17261 {
17262 al_trace("Lanmola segment 1 could not be created!\n");
17263 guys.del(guys.Count()-1);
17264 return 0;
17265 }
17266
17267 ret++;
17268
17269 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17270 {
17271 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17272 {
17273 al_trace("Lanmola segment %d could not be created!\n",i+1);
17274
17275 for(int32_t j=0; j<i+1; j++)
17276 guys.del(guys.Count()-1);
17277
17278 return 0;
17279 }
17280
17281 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17282 ret++;
17283 }
17284 }
17285 break;
17286
17287 case eeMANHAN:
17288 1 id &= 0xFFF;
17289
17290
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17291 {
17292
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17293 {
17294 al_trace("Manhandla head %d could not be created!\n",i+1);
17295
17296 for(int32_t j=0; j<i+1; j++)
17297 {
17298 guys.del(guys.Count()-1);
17299 }
17300
17301 return 0;
17302 }
17303
17304 4 ret++;
17305 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17306 4 }
17307
17308 1 break;
17309
17310 case eeGLEEOK:
17311 {
17312 id &= 0xFFF;
17313
17314 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17315 {
17316 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17317 {
17318 al_trace("Gleeok head %d could not be created!\n",i+1);
17319
17320 for(int32_t j=0; j<i+1; j++)
17321 {
17322 guys.del(guys.Count()-1);
17323 }
17324
17325 return false;
17326 }
17327
17328 c-=guysbuf[id].attributes[3];
17329 ret++;
17330 }
17331 }
17332 break;
17333
17334
17335 case eePATRA:
17336 {
17337 id &= 0xFFF;
17338 int32_t outeyes = 0;
17339
17340 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17341 {
17342 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17343 {
17344 al_trace("Patra outer eye %d could not be created!\n",i+1);
17345
17346 for(int32_t j=0; j<i+1; j++)
17347 guys.del(guys.Count()-1);
17348
17349 return 0;
17350 }
17351 else
17352 outeyes++;
17353
17354 ret++;
17355 }
17356
17357 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17358 {
17359 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17360 {
17361 al_trace("Patra inner eye %d could not be created!\n",i+1);
17362
17363 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17364 guys.del(guys.Count()-1);
17365
17366 return 0;
17367 }
17368
17369 ret++;
17370 }
17371
17372 break;
17373 }
17374 }
17375
17376
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17377 {
17378 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17379 2001 e->screen_spawned = screen;
17380 2001 }
17381
17382 1997 return ret;
17383 1997 }
17384
17385 // Returns number of enemies/segments created
17386 102142 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17387 {
17388 102142 int32_t realid = id&0xFFF;
17389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if( realid > MAXGUYS )
17390 {
17391 return 0;
17392 }
17393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if(id <= 0) return 0;
17394
17395 102142 int32_t ret = 0;
17396 102142 sprite *e=NULL;
17397
17398
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50147 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102142 switch(guysbuf[id&0xFFF].type)
17399 {
17400 //Fixme: possible enemy memory leak. (minor)
17401 case eeWALK:
17402
3/6
✓ Branch 0 taken 50147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50147 times.
✗ Branch 5 not taken.
50147 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17403 50147 break;
17404
17405 case eeLEV:
17406
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17407 3942 break;
17408
17409 case eeTEK:
17410
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17411 5212 break;
17412
17413 case eePEAHAT:
17414
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17415 1825 break;
17416
17417 case eeZORA:
17418
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17419 2797 break;
17420
17421 case eeGHINI:
17422
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17423 461 break;
17424
17425 case eeKEESE:
17426
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17427 11855 break;
17428
17429 case eeWIZZ:
17430
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17431 5335 break;
17432
17433 case eePROJECTILE:
17434
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17435 4429 break;
17436
17437 case eeWALLM:
17438
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17439 998 break;
17440
17441 case eeAQUA:
17442
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17443 126 break;
17444
17445 case eeMOLD:
17446
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17447 618 break;
17448
17449 case eeMANHAN:
17450
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17451 149 break;
17452
17453 case eeGLEEOK:
17454
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17455 168 break;
17456
17457 case eeGHOMA:
17458
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17459 93 break;
17460
17461 case eeLANM:
17462
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17463 420 break;
17464
17465 case eeGANON:
17466
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17467 13 break;
17468
17469 case eeFAIRY:
17470
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17471 732 break;
17472
17473 case eeFIRE:
17474
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17475 758 break;
17476
17477 case eeOTHER:
17478
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17479 7630 break;
17480
17481
17482 case eeSCRIPT01:
17483 case eeSCRIPT02:
17484 case eeSCRIPT03:
17485 case eeSCRIPT04:
17486 case eeSCRIPT05:
17487 case eeSCRIPT06:
17488 case eeSCRIPT07:
17489 case eeSCRIPT08:
17490 case eeSCRIPT09:
17491 case eeSCRIPT10:
17492 case eeSCRIPT11:
17493 case eeSCRIPT12:
17494 case eeSCRIPT13:
17495 case eeSCRIPT14:
17496 case eeSCRIPT15:
17497 case eeSCRIPT16:
17498 case eeSCRIPT17:
17499 case eeSCRIPT18:
17500 case eeSCRIPT19:
17501 case eeSCRIPT20:
17502 {
17503 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17504 {
17505 e = new eScript((zfix)x,(zfix)y,id,clk);
17506 break;
17507 }
17508 else return 0;
17509 }
17510
17511 case eeFFRIENDLY01:
17512 case eeFFRIENDLY02:
17513 case eeFFRIENDLY03:
17514 case eeFFRIENDLY04:
17515 case eeFFRIENDLY05:
17516 case eeFFRIENDLY06:
17517 case eeFFRIENDLY07:
17518 case eeFFRIENDLY08:
17519 case eeFFRIENDLY09:
17520 case eeFFRIENDLY10:
17521 {
17522 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17523 {
17524 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17525 }
17526 else return 0;
17527
17528 }
17529
17530 case eeSPINTILE:
17531
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17532 94 break;
17533
17534 // and these enemies use the misc10/misc2 value
17535 case eeROCK:
17536 {
17537
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17538 {
17539 case 1:
17540
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17541 30 break;
17542
17543 354 case 0:
17544 default:
17545
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17546 354 break;
17547 }
17548
17549 384 break;
17550 }
17551
17552 case eeTRAP:
17553 {
17554
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17555 {
17556 case 1:
17557
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17558 832 break;
17559
17560 1640 case 0:
17561 default:
17562
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17563 1640 break;
17564 }
17565
17566 2472 break;
17567 }
17568
17569 case eeDONGO:
17570 {
17571
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17572 {
17573 case 1:
17574
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17575 48 break;
17576
17577 203 case 0:
17578 default:
17579
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17580 203 break;
17581 }
17582
17583 251 break;
17584 }
17585
17586 case eeDIG:
17587 {
17588
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17589 {
17590 case 1:
17591
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17592 327 break;
17593
17594 76 case 0:
17595 default:
17596
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17597 76 break;
17598 }
17599
17600 403 break;
17601 }
17602
17603 case eePATRA:
17604 {
17605
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17606 {
17607 case 1:
17608
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17609 {
17610
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17611 102 break;
17612 }
17613 [[fallthrough]];
17614 190 case 0:
17615 default:
17616
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17617 190 break;
17618 }
17619
17620 292 break;
17621 }
17622
17623 case eeGUY:
17624 {
17625
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17626 {
17627 case 1:
17628 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17629 break;
17630
17631 5 case 0:
17632 default:
17633
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17634 5 break;
17635 }
17636
17637 5 break;
17638 }
17639
17640 case eeNONE:
17641
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17642 {
17643
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17644 533 break;
17645 }
17646 [[fallthrough]];
17647 default:
17648
17649 return 0;
17650 }
17651
17652 102142 ret++; // Made one enemy.
17653
17654
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101965 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102142 if(z && canfall(id))
17655 {
17656 152 e->z = (zfix)z;
17657 152 }
17658
17659
2/2
✓ Branch 0 taken 101965 times.
✓ Branch 1 taken 177 times.
102142 ((enemy*)e)->ceiling = (z && canfall(id));
17660
17661
1/2
✓ Branch 0 taken 102142 times.
✗ Branch 1 not taken.
102142 if(!guys.add(e))
17662 {
17663 return 0;
17664 }
17665
17666 // add segments of segmented enemies
17667 102142 int32_t c=0;
17668
17669
6/6
✓ Branch 0 taken 100495 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102142 switch(guysbuf[id&0xFFF].type)
17670 {
17671 case eeMOLD:
17672 {
17673 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17674 618 id &= 0xFFF;
17675
17676
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17677 {
17678 //christ this is messy -DD
17679 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17680
17681
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17682 {
17683 al_trace("Moldorm segment %d could not be created!\n",i+1);
17684
17685 for(int32_t j=0; j<i+1; j++)
17686 guys.del(guys.Count()-1);
17687
17688 return 0;
17689 }
17690
17691
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17692 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17693
17694 3150 ret++;
17695 3150 }
17696
17697 618 break;
17698 }
17699
17700 case eeLANM:
17701 {
17702 420 id &= 0xFFF;
17703 420 int32_t shft = guysbuf[id].attributes[1];
17704 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17705
17706
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17707 {
17708 al_trace("Lanmola segment 1 could not be created!\n");
17709 guys.del(guys.Count()-1);
17710 return 0;
17711 }
17712
17713 420 ret++;
17714
17715
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17716 {
17717
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17718 {
17719 al_trace("Lanmola segment %d could not be created!\n",i+1);
17720
17721 for(int32_t j=0; j<i+1; j++)
17722 guys.del(guys.Count()-1);
17723
17724 return 0;
17725 }
17726
17727 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17728 1847 ret++;
17729 1847 }
17730 }
17731 420 break;
17732
17733 case eeMANHAN:
17734 149 id &= 0xFFF;
17735
17736
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17737 {
17738
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17739 {
17740 al_trace("Manhandla head %d could not be created!\n",i+1);
17741
17742 for(int32_t j=0; j<i+1; j++)
17743 {
17744 guys.del(guys.Count()-1);
17745 }
17746
17747 return 0;
17748 }
17749
17750 688 ret++;
17751 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17752 688 }
17753
17754 149 break;
17755
17756 case eeGLEEOK:
17757 {
17758 168 id &= 0xFFF;
17759 168 eGleeok* parent = (eGleeok*)e;
17760
17761
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17762 {
17763
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17764
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17765 {
17766 al_trace("Gleeok head %d could not be created!\n",i+1);
17767
17768 for(int32_t j=0; j<i+1; j++)
17769 {
17770 guys.del(guys.Count()-1);
17771 }
17772
17773 return false;
17774 }
17775
17776 533 head->necktile=parent->necktile;
17777 533 head->dummy_int[1]=parent->necktile;
17778
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17779 {
17780 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17781 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17782 421 }
17783 else
17784 {
17785 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17786 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17787 }
17788 533 head->tile = head->dummy_int[2];
17789
17790 533 c-=guysbuf[id].attributes[3];
17791 533 ret++;
17792 533 }
17793 }
17794 168 break;
17795
17796
17797 case eePATRA:
17798 {
17799 292 id &= 0xFFF;
17800 292 int32_t outeyes = 0;
17801
17802
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17803 {
17804
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17805 {
17806 al_trace("Patra outer eye %d could not be created!\n",i+1);
17807
17808 for(int32_t j=0; j<i+1; j++)
17809 guys.del(guys.Count()-1);
17810
17811 return 0;
17812 }
17813 else
17814 1956 outeyes++;
17815
17816 1956 ret++;
17817 1956 }
17818
17819
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17820 {
17821
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17822 {
17823 al_trace("Patra inner eye %d could not be created!\n",i+1);
17824
17825 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17826 guys.del(guys.Count()-1);
17827
17828 return 0;
17829 }
17830
17831 312 ret++;
17832 312 }
17833
17834 292 break;
17835 }
17836 }
17837
17838
2/2
✓ Branch 0 taken 111048 times.
✓ Branch 1 taken 102142 times.
213190 for (int i = 0; i < ret; i++)
17839 {
17840 111048 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17841 111048 e->screen_spawned = screen;
17842 111048 }
17843
17844 102142 return ret;
17845 102142 }
17846
17847 2059282 bool isjumper(int32_t id)
17848 {
17849
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17850 {
17851 return false;
17852 }
17853
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].type)
17854 {
17855 case eeROCK:
17856 case eeTEK:
17857 9 return true;
17858
17859 case eeWALK:
17860
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17861 93604 }
17862
17863 2047008 return false;
17864 2059282 }
17865
17866
17867 8068 bool isfixedtogrid(int32_t id)
17868 {
17869
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17870 {
17871 return false;
17872 }
17873
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17874 {
17875 case eeWALK:
17876 case eeLEV:
17877 case eeZORA:
17878 case eeDONGO:
17879 case eeGANON:
17880 case eeROCK:
17881 case eeGLEEOK:
17882 case eeAQUA:
17883 case eeLANM:
17884 return true;
17885 }
17886
17887 8068 return false;
17888 8068 }
17889
17890 // Can't fall, can have Z value.
17891 76161798 bool isflier(int32_t id)
17892 {
17893
3/4
✓ Branch 0 taken 76161798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 76050940 times.
76161798 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17894 {
17895 110858 return false;
17896 }
17897
2/2
✓ Branch 0 taken 14067022 times.
✓ Branch 1 taken 61983918 times.
76050940 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17898 {
17899 case eePEAHAT:
17900 case eeKEESE:
17901 case eePATRA:
17902 case eeFAIRY:
17903 case eeGHINI:
17904
17905 // Could theoretically have their Z set by a script
17906 case eeFIRE:
17907 14067022 return true;
17908 break;
17909 }
17910
17911 61983918 return false;
17912 76161798 }
17913
17914 // Can't have Z position
17915 4046103 bool never_in_air(int32_t id)
17916 {
17917
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17918 {
17919 return false;
17920 }
17921
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].type)
17922 {
17923 case eeMANHAN:
17924 case eeMOLD:
17925 case eeLANM:
17926 case eeGLEEOK:
17927 case eeZORA:
17928 case eeLEV:
17929 case eeAQUA:
17930 case eeROCK:
17931 case eeGANON:
17932 case eeTRAP:
17933 case eePROJECTILE:
17934 case eeSPINTILE:
17935 9550 return true;
17936 }
17937
17938 4036553 return false;
17939 4046103 }
17940
17941 2248208 bool canfall(int32_t id)
17942 {
17943
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17944 {
17945 46 return false;
17946 }
17947
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].type)
17948 {
17949 case eeGUY:
17950 {
17951
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17952 40 return false;
17953
17954 switch(guysbuf[id&0xFFF].attributes[9])
17955 {
17956 case 1:
17957 case 2:
17958 return true;
17959
17960 case 0:
17961 case 3:
17962 default:
17963 return false;
17964 }
17965
17966 case eeGHOMA:
17967 case eeDIG:
17968 return false;
17969 }
17970 }
17971
17972
17973
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17974 2248208 }
17975
17976 73903985 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17977 {
17978
3/4
✓ Branch 0 taken 73903985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 73814387 times.
73903985 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17979 {
17980 89598 return false;
17981 }
17982 //Z_scripterrlog("canfall family is %d:\n", family);
17983 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17984 //if ( family == eeFIRE && id >= eSTART )
17985 //{
17986 // Z_scripterrlog("eeFire\n");
17987 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17988 //}
17989
17990 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17991
17992
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71307975 times.
✓ Branch 2 taken 2077477 times.
73814387 switch(guysbuf[id&0xFFF].type)
17993 {
17994 case eeGUY:
17995 {
17996
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17997 2077477 return false;
17998
17999 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18000 {
18001 case 1:
18002 case 2:
18003 return true;
18004
18005 case 0:
18006 case 3:
18007 default:
18008 return false;
18009 }
18010
18011 case eeGHOMA:
18012 case eeDIG:
18013 428935 return false;
18014 }
18015 }
18016
18017
2/2
✓ Branch 0 taken 39108925 times.
✓ Branch 1 taken 32199050 times.
71307975 if(!checkgrav) return true;
18018 39108925 return (moveflags & move_obeys_grav);
18019
18020 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18021 // {
18022 // if ( moveflags & move_obeys_grav ) return true;
18023 // else return false;
18024 // }
18025 // else
18026 // {
18027 // return (moveflags & move_obeys_grav);
18028 // }
18029 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18030 73903985 }
18031
18032 1271 void addfires()
18033 {
18034
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18035 {
18036 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18037 457 int32_t bs = get_qr(qr_BSZELDA);
18038 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18039 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18040 457 }
18041 1271 }
18042
18043 // This function runs one time for every screen on the first frame of a region being loaded.
18044 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18045 37028 static void loadguys(mapscr* scr)
18046 {
18047 37028 int screen = scr->screen;
18048 37028 byte Guy=0;
18049 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18050 // Else use mITEM and ipONETIME
18051 37028 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18052 37028 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18053
18054 37028 mapscr* guyscr = scr;
18055
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36122 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
37028 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18056 {
18057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18058 {
18059 431 Guy=special_warp_return_scr->guy;
18060 431 guyscr = special_warp_return_scr;
18061 431 }
18062 431 }
18063 else
18064 {
18065 36597 Guy=scr->guy;
18066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36597 times.
36597 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18067 36597 mark_visited(screen);
18068 }
18069
18070 114000 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18071
18072 37028 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18073 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18074
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33163 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
37028 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18075 {
18076
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18077 {
18078 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18079 11 guys.spr(0)->hxofs=1000;
18080 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18081 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18082 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18083 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18084 11 return;
18085 }
18086
18087
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18088
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18089 4 : (guyscr->roomflags&RFL_GUYFIRES);
18090
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18091 1271 addfires();
18092
18093
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18094
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18095 13 Guy=0;
18096
18097
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18098 {
18099 case rSP_ITEM:
18100 case rGRUMBLE:
18101 case rBOMBS:
18102 case rARROWS:
18103 case rSWINDLE:
18104 case rMUPGRADE:
18105 case rLEARNSLASH:
18106 case rTAKEONE:
18107
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18108 55 Guy=0;
18109
18110 167 break;
18111
18112 case rREPAIR:
18113 if (get_qr(qr_OLD_DOORREPAIR)) break;
18114 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18115 Guy=0;
18116
18117 break;
18118 case rRP_HC:
18119 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18120 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18121 Guy=0;
18122
18123 break;
18124 case rMONEY:
18125
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18126 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18127 Guy=0;
18128
18129 break;
18130
18131 case rTRIFORCE:
18132 {
18133 45 int32_t tc = TriforceCount();
18134
18135
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18136 {
18137
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18138 10 Guy=0;
18139 9 }
18140 else
18141 {
18142
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18143 33 Guy=0;
18144 }
18145 }
18146 43 break;
18147 }
18148
18149
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18150 {
18151
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18152 1162 blockpath=true;
18153
18154
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18155 783 sfx(WAV_SCALE);
18156
18157
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18158 1195 Hero.Freeze();
18159 1195 }
18160 1302 }
18161
5/6
✓ Branch 0 taken 33904 times.
✓ Branch 1 taken 1809 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33833 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1809 times.
35713 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18162 {
18163 71 sfx(WAV_SCALE);
18164 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18165 71 }
18166
18167 111045 loaditem(scr, dx, dy);
18168
18169 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18170 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18171
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36996 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
37015 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18172 {
18173
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18174 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18175 15 }
18176 37026 }
18177
18178 35784 void loadguys()
18179 {
18180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35784 times.
35784 if (loaded_guys)
18181 return;
18182
18183 35784 loaded_guys = true;
18184 35784 repaircharge = 0;
18185 35784 adjustmagic = false;
18186 35784 learnslash = false;
18187
2/2
✓ Branch 0 taken 107352 times.
✓ Branch 1 taken 35784 times.
143136 for (int32_t i=0; i<3; i++)
18188 {
18189 107352 prices[i] = 0;
18190 107352 }
18191
18192 72812 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18193 37028 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18194 37028 loadguys(scr);
18195 37028 });
18196 35784 }
18197
18198 37034 void loaditem(mapscr* scr, int offx, int offy)
18199 {
18200 37034 int screen = scr->screen;
18201 37034 byte Item = 0;
18202
18203
2/2
✓ Branch 0 taken 36128 times.
✓ Branch 1 taken 906 times.
37034 if(screen<128)
18204 {
18205 36128 Item=scr->item;
18206
18207
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 34535 times.
✓ Branch 2 taken 32910 times.
✓ Branch 3 taken 3218 times.
36128 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18208 {
18209
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3159 times.
3218 if(scr->flags8&fSECRETITEM)
18210 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18211
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1995 times.
3159 else if(scr->flags&fITEM)
18212 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18213
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1886 times.
1995 else if(scr->flags11&efCARRYITEM)
18214 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18215 else
18216 {
18217 1886 int x = scr->itemx;
18218
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1886 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18219 -170 :
18220 1886 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18221
3/6
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1886 times.
✗ Branch 5 not taken.
3772 add_item_for_screen(screen, new item(offx + x, offy + y,
18222
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1871 times.
✗ Branch 9 not taken.
1886 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18223
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1781 times.
1886 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18224 1886 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18225 }
18226 3218 }
18227 36128 }
18228
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18229 {
18230
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18231
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18232 {
18233 163 Item = special_warp_return_scr->catchall;
18234
18235
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18236 {
18237 162 int x = scr->itemx;
18238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18239 -170 :
18240 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18241
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18242
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18243 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18244 162 }
18245 163 }
18246 475 }
18247 37034 }
18248
18249 957 void never_return(int32_t screen, int32_t index)
18250 {
18251
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18252 191 goto doit;
18253
18254
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18255
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18256 {
18257 437 goto dontdoit;
18258 329 }
18259
18260 doit:
18261 520 setmapflag(get_scr(screen), mNEVERRET);
18262 dontdoit:
18263 957 return;
18264 }
18265
18266 63753 bool slowguy(int32_t id)
18267 {
18268
2/4
✓ Branch 0 taken 63753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63753 times.
63753 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18269 {
18270 return false;
18271 }
18272
18273 63753 id = id&0xFFF;
18274
18275
2/2
✓ Branch 0 taken 54110 times.
✓ Branch 1 taken 9643 times.
63753 switch(id)
18276 {
18277 case eOCTO1S:
18278 case eOCTO2S:
18279 case eOCTO1F:
18280 case eOCTO2F:
18281 case eLEV1:
18282 case eLEV2:
18283 case eROCK:
18284 case eBOULDER:
18285 9643 return true;
18286 }
18287
18288 54110 return false;
18289 63753 }
18290
18291 83364 static bool ok2add(mapscr* scr, int32_t id)
18292 {
18293
2/4
✓ Branch 0 taken 83364 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83364 times.
83364 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18294 {
18295 return false;
18296 }
18297
18298 83364 id = id&0xFFF;
18299
18300
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82535 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83364 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18301 464 return false;
18302
18303
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82259 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82900 switch(guysbuf[id].type)
18304 {
18305 // I added a special case for shooters because having traps on the same screen
18306 // was preventing them from spawning due to TMPNORET. This means they will
18307 // never stay dead, though, so it may not be the best solution. - Saf
18308 case eePROJECTILE:
18309 376 return true;
18310
18311
18312 case eeDIG:
18313 {
18314
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18315 {
18316 case 1:
18317
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18318 79 return !getmapflag(scr, mTMPNORET);
18319
18320 47 return true;
18321
18322 75 case 0:
18323 default:
18324 75 return true;
18325 }
18326 }
18327 case eeGANON:
18328 case eeTRAP:
18329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18330
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18331 [[fallthrough]];
18332 default:
18333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82259 times.
82259 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18334 82259 break;
18335 }
18336
18337
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 61281 times.
82259 if(!get_qr(qr_NOTMPNORET))
18338 61281 return !getmapflag(scr, mTMPNORET);
18339
18340 20978 return true;
18341 83364 }
18342
18343 1634105 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18344 {
18345
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1345264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634105 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18346 {
18347 1345264 return;
18348 }
18349
18350 288841 int32_t ctype = rpos_handle.ctype();
18351
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18352
18353 12108 auto [x, y] = rpos_handle.xy();
18354
18355 4036 int32_t cx=-1000, cy=-1000;
18356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18357 {
18358
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18359 {
18360 1508 cx=x+4;
18361 1508 cy=y+7;
18362 1508 }
18363
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18364 {
18365 1315 cx=x-8;
18366 1315 cy=y-1;
18367 1315 }
18368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18369 {
18370 1213 cx=x;
18371 1213 cy=y;
18372 1213 }
18373 4036 }
18374 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18375 {
18376 cx=x;
18377 cy=y;
18378 }
18379
18380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18381 {
18382
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18383 {
18384
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18385 {
18386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18387 4 return; // No point deleting it. A script might be toying with it in some way.
18388 else
18389 guys.del(j);
18390 }
18391 9750 }
18392
18393 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18394 4032 }
18395 1634105 }
18396
18397 34365 static void activate_fireball_statues(mapscr* scr)
18398 {
18399
2/2
✓ Branch 0 taken 32946 times.
✓ Branch 1 taken 1419 times.
34365 if (!(scr->flags11&efFIREBALLS))
18400 {
18401 32946 return;
18402 }
18403
18404 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18405 249744 activate_fireball_statue(rpos_handle);
18406 249744 });
18407 34365 }
18408
18409 35048 void load_default_enemies(mapscr* scr)
18410 {
18411 35048 int screen = scr->screen;
18412 40513 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18413
18414 35048 wallm_load_clk=frame-80;
18415
18416
2/2
✓ Branch 0 taken 33152 times.
✓ Branch 1 taken 1896 times.
35048 if(scr->flags11&efZORA)
18417 {
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18419 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18420 1896 }
18421
18422
2/2
✓ Branch 0 taken 34870 times.
✓ Branch 1 taken 178 times.
35048 if(scr->flags11&efTRAP4)
18423 {
18424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18425 {
18426 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18427 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18428 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18429 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18430 178 }
18431 178 }
18432
18433 6203496 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18434 6168448 int32_t ctype = rpos_handle.ctype();
18435 6168448 int32_t cflag = rpos_handle.sflag();
18436 6168448 int32_t cflag_i = rpos_handle.cflag();
18437
18438
4/6
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168102 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168102 times.
6168448 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18439 {
18440 346 auto [x, y] = rpos_handle.xy();
18441
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18442 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18443 346 }
18444
4/6
✓ Branch 0 taken 6168102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167896 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167896 times.
6168102 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18445 {
18446 206 auto [x, y] = rpos_handle.xy();
18447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18448 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18449 206 }
18450
4/6
✓ Branch 0 taken 6167896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167618 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167618 times.
6167896 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18451 {
18452 278 auto [x, y] = rpos_handle.xy();
18453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18454 {
18455
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18456 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18457 278 }
18458 278 }
18459
4/6
✓ Branch 0 taken 6167618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167219 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167219 times.
6167618 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18460 {
18461 399 auto [x, y] = rpos_handle.xy();
18462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18463 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18464 399 }
18465
4/6
✓ Branch 0 taken 6167219 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6166786 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6166786 times.
6167219 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18466 {
18467 433 auto [x, y] = rpos_handle.xy();
18468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18469 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18470 433 }
18471
18472
1/2
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
6168448 if(ctype==cSPINTILE1)
18473 {
18474 awaken_spinning_tile(rpos_handle);
18475 }
18476 6168448 });
18477
18478
2/2
✓ Branch 0 taken 34992 times.
✓ Branch 1 taken 56 times.
35048 if(scr->flags11&efTRAP2)
18479 {
18480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18481 {
18482
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18483 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18484
18485
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18486 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18487 56 }
18488 56 }
18489
18490
2/2
✓ Branch 0 taken 34965 times.
✓ Branch 1 taken 83 times.
35048 if(scr->flags11&efROCKS)
18491 {
18492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18493 {
18494 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18495 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18496 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18497 83 }
18498 83 }
18499 35048 }
18500
18501 #define SLOPE_STAGE_COMBOS 0
18502 #define SLOPE_STAGE_FFCS 1
18503 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18504
18505 20910624 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18506 {
18507
2/2
✓ Branch 0 taken 4645463 times.
✓ Branch 1 taken 16265161 times.
20910624 if (stage == SLOPE_STAGE_COMBOS)
18508 16265161 return (region_num_rpos*arg1)+arg2;
18509
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 144909 times.
4645463 if (stage == SLOPE_STAGE_FFCS)
18510 4500554 return (region_num_rpos*7)+arg1;
18511
1/2
✓ Branch 0 taken 144909 times.
✗ Branch 1 not taken.
144909 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18512 144909 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18513 // TODO: what about FFCs from bordering screens?
18514
18515 assert(false);
18516 return 0;
18517 20910624 }
18518
18519 16265161 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18520 {
18521 16265161 mapscr* s = rpos_handle.scr;
18522 16265161 auto& cmb = rpos_handle.combo();
18523
18524 16265161 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18525 16265161 auto it = slopes.find(id);
18526
18527 16265161 bool wasSlope = it!=slopes.end();
18528 16265161 bool isSlope = cmb.type == cSLOPE;
18529
18530
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16265025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16265161 if(isSlope && !wasSlope)
18531 {
18532 272 auto [x, y] = rpos_handle.xy();
18533 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18534 136 }
18535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16265025 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16265025 else if(wasSlope && !isSlope)
18536 {
18537 slopes.erase(it);
18538 }
18539 16265161 }
18540
18541 144909 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18542 {
18543 144909 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18544 144909 auto it = slopes.find(id);
18545
18546 144909 bool wasSlope = it!=slopes.end();
18547 144909 bool isSlope = is_slope;
18548
18549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 if(isSlope && !wasSlope)
18550 {
18551 static std::vector<word> TMP;
18552 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18553 TMP.resize(num_border_combos * 7 * 4);
18554
18555 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18556 TMP[tmp_index] = cid;
18557 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18558 }
18559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 else if(wasSlope && !isSlope)
18560 {
18561 slopes.erase(it);
18562 }
18563 144909 }
18564
18565 // Load a single column or row from a nearby screen, and load its slopes.
18566 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18567 {
18568 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18569
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18570 171 return;
18571
18572 3713 int offx = 0;
18573 3713 int offy = 0;
18574
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18575 913 offy = -16;
18576
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18577 862 offy = world_h;
18578
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18579 968 offx = -16;
18580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18581 970 offx = world_w;
18582
18583
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18584 {
18585 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18586
2/2
✓ Branch 0 taken 10824 times.
✓ Branch 1 taken 15167 times.
25991 if (!scr) continue;
18587
18588 10824 int slope_count = layer * (16*2);
18589
18590
4/4
✓ Branch 0 taken 7999 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5169 times.
10824 if (dir == left || dir == right)
18591 {
18592 5655 int x = dir == left ? 15 : 0;
18593
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18594 {
18595 62205 int pos = y * 16 + x;
18596 62205 int cid = scr->data[pos];
18597 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18598
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18599 62205 }
18600 5655 }
18601
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2675 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5169 else if (dir == up || dir == down)
18602 {
18603 5169 int y = dir == up ? 10 : 0;
18604
2/2
✓ Branch 0 taken 82704 times.
✓ Branch 1 taken 5169 times.
87873 for (int x = 0; x < 16; x++)
18605 {
18606 82704 int pos = y * 16 + x;
18607 82704 int cid = scr->data[pos];
18608 82704 bool is_slope = combobuf[cid].type == cSLOPE;
18609
1/2
✓ Branch 0 taken 82704 times.
✗ Branch 1 not taken.
82704 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18610 82704 }
18611 5169 }
18612
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
✓ Branch 2 taken 10824 times.
25991 }
18613 3884 }
18614
18615 35854 void update_slope_comboposes()
18616 {
18617 14916654 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18618 14880800 update_slope_combopos(rpos_handle);
18619 14880800 });
18620
18621
2/2
✓ Branch 0 taken 34883 times.
✓ Branch 1 taken 971 times.
35854 if (Hero.sideview_mode())
18622 {
18623 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18624
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18625 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18626 971 });
18627 971 }
18628
18629 35854 update_slopes();
18630 35854 }
18631
18632 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18633 1384361 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18634 {
18635 1384361 delete_fireball_shooter(rpos_handle);
18636 1384361 }
18637
18638 //Placeholder in case we need it.
18639 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18640 {
18641 return;
18642 }
18643
18644 // Everything that must be done after we change a screen's combo to another combo. -L
18645 1384361 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18646 {
18647 1384361 rpos_handle.scr->valid |= mVALID;
18648 1384361 activate_fireball_statue(rpos_handle);
18649
18650
2/2
✓ Branch 0 taken 1384267 times.
✓ Branch 1 taken 94 times.
1384361 if(rpos_handle.ctype()==cSPINTILE1)
18651 {
18652 94 awaken_spinning_tile(rpos_handle);
18653 94 }
18654
18655 1384361 update_slope_combopos(rpos_handle);
18656 1384361 }
18657
18658 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18659 {
18660 4500554 ffcdata* ff = ffc_handle.ffc;
18661 4500554 auto& cmb = ffc_handle.combo();
18662
18663 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18664 4500554 auto it = slopes.find(id);
18665
18666 4500554 bool wasSlope = it!=slopes.end();
18667
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18669 {
18670 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18671 }
18672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18673 {
18674 slopes.erase(it);
18675 }
18676
18677 4500554 ffc_handle.scr->ffcCountMarkDirty();
18678 4500554 }
18679
18680 4414 void screen_combo_modify_pre(int32_t cid)
18681 {
18682 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18683
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18684 {
18685 5195 screen_combo_modify_preroutine(rpos_handle);
18686 5195 }
18687 2808608 });
18688 4414 }
18689 4414 void screen_combo_modify_post(int32_t cid)
18690 {
18691 4414 combo_caches::refresh(cid);
18692
18693 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18694
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18695 {
18696 5195 screen_combo_modify_postroutine(rpos_handle);
18697 5195 }
18698 2808608 });
18699
18700 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18701
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18702 {
18703 58 screen_ffc_modify_postroutine(ffc_handle);
18704 58 }
18705 139772 });
18706 4414 }
18707
18708 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18709 {
18710 94 int cid = rpos_handle.data();
18711 94 int cset = rpos_handle.cset();
18712 282 auto [x, y] = rpos_handle.xy();
18713
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18714 94 }
18715
18716 // It stands for next_side_pos
18717 // moves sle_x and sle_y to the next position
18718 11464 void nsp(bool random)
18719 {
18720
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18721 {
18722
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18723 {
18724 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18725 1634 sle_y = (zc_oldrand()%10)*16;
18726 1634 }
18727 else
18728 {
18729 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18730 1627 sle_x = (zc_oldrand()%15)*16;
18731 }
18732
18733 3261 return;
18734 }
18735
18736
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18737 {
18738
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18739 1855 sle_y+=16;
18740 else
18741 180 sle_x+=16;
18742 2035 }
18743
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18744 {
18745
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18746 2430 sle_x+=16;
18747 else
18748 166 sle_y-=16;
18749 2596 }
18750
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18751 {
18752
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18753 1404 sle_y-=16;
18754 else
18755 148 sle_x-=16;
18756 1552 }
18757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18758 {
18759
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18760 2020 sle_x-=16;
18761 else
18762 sle_y+=16;
18763 2020 }
18764 11464 }
18765
18766 // moves sle_x and sle_y to the next available position
18767 // returns the direction the enemy should face
18768 2429 int32_t next_side_pos(int32_t screen, bool random)
18769 {
18770 bool blocked;
18771 2429 int32_t c=0;
18772 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18773
18774 2429 do
18775 {
18776
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18777 22928 int x = sle_x + offx;
18778 22928 int y = sle_y + offy;
18779
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18780
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18781
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18782
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18783 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18784
18785
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18786 1 return -1;
18787
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18788 11463 while(blocked);
18789
18790 2428 int32_t dir=0;
18791
18792
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18793
18794
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18795
18796
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18797
18798
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18799
18800 2428 return dir;
18801 2429 }
18802
18803 bool can_side_load(int32_t id)
18804 {
18805 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18806 {
18807 return false;
18808 }
18809
18810 id = id&0xFFF;
18811
18812 switch(guysbuf[id].type)
18813 {
18814 case eeTEK:
18815 case eeLEV:
18816 case eeAQUA:
18817 case eeDONGO:
18818 case eeMANHAN:
18819 case eeGLEEOK:
18820 case eeDIG:
18821 case eeGHOMA:
18822 case eeLANM:
18823 case eePATRA:
18824 case eeGANON:
18825 case eePROJECTILE:
18826 return false;
18827 break;
18828 }
18829
18830 return true;
18831 }
18832
18833 bool enemy_spawning_has_checked_been_here;
18834 static bool enemy_spawning_has_been_here;
18835
18836 35048 static bool check_if_recently_visited()
18837 {
18838
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34526 times.
35048 if (enemy_spawning_has_checked_been_here)
18839 522 return enemy_spawning_has_been_here;
18840
18841 34526 int mi = mapind(cur_map, cur_screen);
18842
18843 34526 enemy_spawning_has_been_here = false;
18844
2/2
✓ Branch 0 taken 207156 times.
✓ Branch 1 taken 34526 times.
241682 for (int i = 0; i < 6; i++)
18845
2/2
✓ Branch 0 taken 197577 times.
✓ Branch 1 taken 9579 times.
216735 if (visited[i] == mi)
18846 9579 enemy_spawning_has_been_here = true;
18847
18848
2/2
✓ Branch 0 taken 9579 times.
✓ Branch 1 taken 24947 times.
34526 if (!enemy_spawning_has_been_here)
18849 {
18850 24947 visited[vhead] = mi; //If not, it adds it to the array,
18851 24947 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18852 24947 }
18853
18854 34526 enemy_spawning_has_checked_been_here = true;
18855 34526 return enemy_spawning_has_been_here;
18856 35048 }
18857
18858 static std::array<bool, MAPSCRS> script_sle;
18859
18860 static int32_t sle_pattern = 0;
18861 static void script_side_load_enemies(mapscr* scr)
18862 {
18863 if (script_sle[scr->screen] || sle_clk) return;
18864
18865 sle_cnt = 0;
18866 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18867 ++sle_cnt;
18868 script_sle[scr->screen] = true;
18869 sle_pattern = scr->pattern;
18870 sle_clk = 0;
18871 }
18872
18873 54516 static void side_load_enemies(mapscr* scr)
18874 {
18875 54516 int screen = scr->screen;
18876
18877
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18878 {
18879 683 sle_pattern = scr->pattern;
18880 683 sle_cnt = 0;
18881 683 int32_t guycnt = 0;
18882
18883 683 int mi = mapind(cur_map, screen);
18884 683 bool reload=true;
18885 683 bool unbeatablereload = true;
18886
18887 683 load_default_enemies(scr);
18888
18889 683 bool beenhere = check_if_recently_visited();
18890
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18891 {
18892 42 sle_cnt=0;
18893 42 reload=false;
18894 42 }
18895
18896
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18897 {
18898 641 sle_cnt = game->guys[mi];
18899
18900
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18901 641 || sle_cnt==0)
18902 {
18903
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18904 1054 ++sle_cnt;
18905 221 }
18906
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18907 {
18908 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18909 {
18910 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18911 {
18912 unbeatablereload = false;
18913 }
18914 }
18915 if (unbeatablereload)
18916 {
18917 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18918 {
18919 ++sle_cnt;
18920 }
18921 }
18922 }
18923 641 }
18924
18925
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18926 {
18927 31 sle_cnt = 0;
18928
18929
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18930 108 ++sle_cnt;
18931 31 }
18932
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18933 sle_cnt = 0;
18934
18935
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18936 2446 ++guycnt;
18937
18938 683 game->guys[mi] = guycnt;
18939 683 }
18940
18941
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18942 {
18943 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18944 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18945
18946
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18947 {
18948 234 return;
18949 }
18950
18951 2195 int32_t enemy_slot=guys.Count();
18952
18953
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18954 sle_cnt--;
18955
18956
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18957 {
18958
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18959 {
18960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18961 {
18962 2195 guys.spr(enemy_slot)->dir = dir;
18963 2195 }
18964
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18965 {
18966 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18967 {
18968 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18969 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18970 }
18971 }
18972 2195 }
18973 2195 }
18974 2195 }
18975
18976
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18977 {
18978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18979 script_sle[screen] = false;
18980 else
18981 {
18982 578 get_screen_state(screen).loaded_enemies = true;
18983 }
18984 578 sle_clk = 0;
18985 578 }
18986 54516 }
18987
18988 1253524 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18989 {
18990
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 1137136 times.
1253524 if (!is_in_scrolling_region())
18991
2/4
✓ Branch 0 taken 1137136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137136 times.
1137136 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18992 {
18993 return false; //never 0, never OoB.
18994 }
18995 // No corner enemies
18996
6/6
✓ Branch 0 taken 1082517 times.
✓ Branch 1 taken 171007 times.
✓ Branch 2 taken 41285 times.
✓ Branch 3 taken 1123802 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253524 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18997 212292 return false;
18998
18999 //Is a no spawn combo...
19000
4/4
✓ Branch 0 taken 1123788 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1123794 times.
1123802 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19001 20 return false;
19002
19003 // No enemies in dungeon walls
19004
2/2
✓ Branch 0 taken 468705 times.
✓ Branch 1 taken 655089 times.
1123794 if (isdungeon(scr->screen))
19005 {
19006 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19007
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19008 319264 return false;
19009 335825 }
19010
19011 // Too close to hero
19012
4/4
✓ Branch 0 taken 77038 times.
✓ Branch 1 taken 727492 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76937 times.
804530 if(tooclose(x,y,40) && t<11)
19013 76937 return false;
19014
19015 // Can't fly onto it?
19016
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587982 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788808 if(isflier(scr->enemy[i])&&
19017
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19018
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19019 25645 return false;
19020
19021 // Can't jump onto it?
19022 if
19023 (
19024
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790656 guysbuf[scr->enemy[i]].type==eeTEK
19025
19026
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613226 times.
701948 &&
19027 (
19028
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19029
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19030
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19031
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19032 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19033 )
19034 )
19035 {
19036 18 return false;
19037 }
19038
19039 // Other off-limit combos
19040
6/6
✓ Branch 0 taken 587958 times.
✓ Branch 1 taken 113972 times.
✓ Branch 2 taken 499254 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276494 times.
✓ Branch 5 taken 222760 times.
1201184 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19041
2/2
✓ Branch 0 taken 282052 times.
✓ Branch 1 taken 217202 times.
499254 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19042 499254 guysbuf[scr->enemy[i]].type!=eeZORA)
19043 222760 return false;
19044
19045 // Don't ever generate enemies on these combos!
19046
4/4
✓ Branch 0 taken 478864 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478870 times.
479170 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19047 312 return false;
19048
19049 //BS Dodongos need at least 2 spaces.
19050
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477831 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478870 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19051 {
19052
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19053
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19054
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19055 ((y>144)||_walkflag(x, y+24,2)))
19056 {
19057 return false;
19058 }
19059 19 }
19060
19061 478864 return true;
19062 1147384 }
19063
19064 160640 bool is_ceiling_pattern(int32_t i)
19065 {
19066
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160620 times.
160640 return (i==pCEILING || i==pCEILINGR);
19067 }
19068
19069 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19070 {
19071 5955 std::vector<rpos_t> freeposcache;
19072
19073
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19074 {
19075
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19076 {
19077
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19078 {
19079
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19080 421055 }
19081 1048080 }
19082 65505 }
19083
19084
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19085
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19086
19087 11 return rpos_t::None;
19088 5955 }
19089
19090 81131 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19091 {
19092 81131 int screen = scr->screen;
19093 81131 int x = 0;
19094 81131 int y = 0;
19095 81131 bool placed=false;
19096 81131 int32_t t=-1;
19097
19098 // First: enemy combo flags
19099
2/2
✓ Branch 0 taken 805424 times.
✓ Branch 1 taken 63764 times.
869188 for(int32_t sy=0; sy<176; sy+=16)
19100 {
19101
2/2
✓ Branch 0 taken 12757620 times.
✓ Branch 1 taken 788057 times.
13545677 for(int32_t sx=0; sx<256; sx+=16)
19102 {
19103 12757620 x = offx + sx;
19104 12757620 y = offy + sy;
19105 12757620 int32_t cflag = MAPFLAG(x, y);
19106 12757620 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19107
19108
2/4
✓ Branch 0 taken 12757620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12757620 times.
✗ Branch 3 not taken.
12757620 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19109 {
19110 if(!ok2add(scr, scr->enemy[i]))
19111 {
19112 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19113 }
19114 else
19115 {
19116 addenemy_z(screen,x,
19117 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19118 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19119
19120 ++guycnt;
19121
19122 placed=true;
19123 goto placed_enemy;
19124 }
19125 }
19126
19127
4/4
✓ Branch 0 taken 12740204 times.
✓ Branch 1 taken 17416 times.
✓ Branch 2 taken 12740204 times.
✓ Branch 3 taken 17416 times.
12757620 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19128 {
19129
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17367 times.
17416 if(!ok2add(scr, scr->enemy[i]))
19130 {
19131
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19132 49 }
19133 else
19134 {
19135 34734 addenemy_z(screen,x,
19136
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17367 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19137
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17367 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19138
19139 17367 ++guycnt;
19140
19141 17367 placed=true;
19142 17367 goto placed_enemy;
19143 }
19144 49 }
19145 12740253 }
19146 788057 }
19147
19148 // Next: enemy pattern
19149
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58767 times.
✓ Branch 2 taken 58030 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58030 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58030 times.
63764 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19150 {
19151 58030 do
19152 {
19153
19154 // NES positions
19155 99525 pos%=9;
19156 99525 x=offx+stx[loadside][pos];
19157 99525 y=offy+sty[loadside][pos];
19158 99525 ++pos;
19159 99525 ++t;
19160
2/2
✓ Branch 0 taken 41495 times.
✓ Branch 1 taken 58030 times.
157555 }
19161
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99304 times.
99525 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19162 58030 }
19163
19164
4/4
✓ Branch 0 taken 58030 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57809 times.
63764 if(t<0 || t >= 20) // above enemy pattern failed
19165 {
19166 // Final chance: find a random position anywhere onscreen
19167 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19168
19169
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19170 {
19171 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19172 5944 }
19173 else // All opportunities failed - abort
19174 {
19175 11 return;
19176 }
19177 5944 }
19178
19179 {
19180 63753 int32_t c=0;
19181 63753 c=clk;
19182
19183
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54110 times.
63753 if(!slowguy(scr->enemy[i]))
19184 54110 ++fastguys;
19185
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19186 1586 c=-15*(i-fastguys+2);
19187 else
19188 8057 c=-15*(i+1);
19189
19190
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63753 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19191 {
19192 // Special case for blue leevers
19193
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19194 761 c=-15*(i+1);
19195 else
19196 28399 c=-15;
19197 29160 }
19198
19199
2/2
✓ Branch 0 taken 62953 times.
✓ Branch 1 taken 800 times.
63753 if(!ok2add(scr, scr->enemy[i]))
19200 {
19201
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19202 800 }
19203 else
19204 {
19205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62953 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62953 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19206 {
19207
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125906 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19208
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62953 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19209
19210 62953 ++guycnt;
19211 62953 }
19212 }
19213
19214 63753 placed=true;
19215 63753 } // if(t < 20)
19216
19217 placed_enemy:
19218
19219 // I don't like this, but it seems to work...
19220 static bool foundCarrier;
19221
19222
2/2
✓ Branch 0 taken 59508 times.
✓ Branch 1 taken 21612 times.
81120 if(i==0)
19223 21612 foundCarrier=false;
19224
19225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81120 times.
81120 if(placed)
19226 {
19227
4/4
✓ Branch 0 taken 21612 times.
✓ Branch 1 taken 59508 times.
✓ Branch 2 taken 21443 times.
✓ Branch 3 taken 169 times.
81120 if(i==0 && scr->flags11&efLEADER)
19228 {
19229 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19230
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19231 {
19232 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19233
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19234 {
19235 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19236 }
19237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19238 {
19239 162 e->leader = true;
19240 162 }
19241 162 }
19242 169 }
19243
19244 81120 ScreenItemState item_state = get_screen_state(screen).item_state;
19245
5/6
✓ Branch 0 taken 80878 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80801 times.
81120 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19246 {
19247 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19248
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19249 {
19250 77 e->itemguy = true;
19251 77 foundCarrier=true;
19252 77 }
19253 77 }
19254 81120 }
19255 81131 }
19256
19257 // returns index of first sprite with matching id, -1 if none found
19258 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19259 {
19260 246 int count = guys.Count();
19261
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19262 {
19263 366 enemy* e = (enemy*)guys.spr(i);
19264
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19265 {
19266 239 return e;
19267 }
19268 127 }
19269
19270 7 return nullptr;
19271 246 }
19272
19273 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19274 {
19275 int count = guys.Count();
19276 for(int32_t i=0; i<count; i++)
19277 {
19278 enemy* e = (enemy*)guys.spr(i);
19279 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19280 {
19281 if (n > 1) --n;
19282 else return e;
19283 }
19284 }
19285 return nullptr;
19286 }
19287
19288 bool scriptloadenemies(int screen)
19289 {
19290 auto& state = get_screen_state(screen);
19291 state.loaded_enemies = true;
19292
19293 if (sle_clk || script_sle[screen]) return false;
19294
19295 mapscr* scr = get_scr(screen);
19296 if(scr->pattern==pNOSPAWN) return false;
19297
19298 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19299 {
19300 script_side_load_enemies(scr);
19301 return true;
19302 }
19303
19304 auto [x, y] = translate_screen_coordinates_to_world(screen);
19305 int32_t pos=zc_oldrand()%9;
19306 int32_t clk=-15,fastguys=0;
19307 int32_t i=0,guycnt=0;
19308 int32_t loadcnt = 10;
19309
19310 for(; i<loadcnt && scr->enemy[i]>0; i++)
19311 {
19312 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19313 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19314 if (guys.Count() > preguycount)
19315 {
19316 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19317 {
19318 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19319 {
19320 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19321 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19322 }
19323 }
19324 }
19325 --clk;
19326 }
19327 return true;
19328 }
19329
19330 14267721 void loadenemies()
19331 {
19332 28915600 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19333 14647879 int screen = scr->screen;
19334 14647879 auto& state = get_screen_state(screen);
19335
2/2
✓ Branch 0 taken 14232652 times.
✓ Branch 1 taken 415227 times.
14647879 if (state.loaded_enemies)
19336 14232652 return;
19337
19338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415227 times.
415227 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19339 return;
19340
19341 // dungeon basements
19342 static byte dngn_enemy_x[4] = {32,96,144,208};
19343
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266263 times.
415227 if (cur_screen>=128)
19344 {
19345
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19347 {
19348 for(int32_t i=0; i<10; i++)
19349 {
19350 if ( scr->enemy[i] )
19351 {
19352 int32_t preguycount = guys.Count();
19353 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19354 if (guys.Count() > preguycount)
19355 {
19356 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19357 {
19358 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19359 {
19360 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19361 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19362 }
19363 }
19364 }
19365 }
19366 }
19367 }
19368 else
19369 {
19370
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19371 {
19372 1900 int32_t preguycount = guys.Count();
19373
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19375 {
19376
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19377 {
19378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19379 {
19380 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19381 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19382 4 }
19383 4 }
19384 1900 }
19385 1900 }
19386 }
19387
19388 475 state.loaded_enemies = true;
19389 475 return;
19390 }
19391
19392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266263 times.
266263 if (scr->pattern == pNOSPAWN)
19393 return;
19394
19395 // TODO: configure when screen enemies spawn.
19396
2/2
✓ Branch 0 taken 88971 times.
✓ Branch 1 taken 177292 times.
266263 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19397 177292 return;
19398
19399
4/4
✓ Branch 0 taken 50524 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34455 times.
88971 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19400 {
19401 54516 side_load_enemies(scr);
19402 54516 return;
19403 }
19404
19405 34455 state.loaded_enemies = true;
19406
19407 // check if it's the dungeon boss and it has been beaten before
19408
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34096 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34455 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19409 90 return;
19410
19411 34365 int32_t loadcnt = 10;
19412 34365 int16_t mi = mapind(cur_map, screen);
19413 34365 bool beenhere = check_if_recently_visited();
19414
19415 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19416 34365 bool reload = true;
19417
4/4
✓ Branch 0 taken 9722 times.
✓ Branch 1 taken 24643 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5014 times.
34365 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19418 {
19419 5014 loadcnt = 0; //It will tell it not to load any enemies,
19420 5014 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19421 5014 }
19422
19423 34365 bool unbeatablereload = true;
19424
2/2
✓ Branch 0 taken 5014 times.
✓ Branch 1 taken 29351 times.
34365 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19425 {
19426 29351 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19427
19428
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29351 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19430 19062 loadcnt = 10; //That means all enemies need to be respawned.
19431
3/4
✓ Branch 0 taken 24643 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24643 times.
✗ Branch 3 not taken.
29351 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19432 {
19433 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19434 {
19435 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19436 {
19437 unbeatablereload = false;
19438 }
19439 }
19440 if (unbeatablereload)
19441 {
19442 loadcnt = 10;
19443 }
19444 }
19445 29351 }
19446
19447
4/4
✓ Branch 0 taken 32904 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32711 times.
34365 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19448 1654 loadcnt = 10; //All enemies also need to be respawned.
19449
19450 // do enemies that are always loaded
19451 34365 load_default_enemies(scr);
19452 34365 activate_fireball_statues(scr);
19453
19454 34365 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19455 34365 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19456 34365 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19457
4/4
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 100340 times.
✓ Branch 2 taken 81131 times.
✓ Branch 3 taken 34365 times.
115496 for(; i<loadcnt && scr->enemy[i]>0; i++)
19458 {
19459 81131 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19460 81131 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19461
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80320 times.
81131 if (guys.Count() > preguycount)
19462 {
19463
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 2352 times.
80320 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19464 {
19465
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2348 times.
2352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19466 {
19467 2348 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19468 2348 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19469 2348 }
19470 2352 }
19471 80320 }
19472
19473 81131 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19474 81131 }
19475
19476 34365 game->guys[mi] = guycnt;
19477 14647879 });
19478 14267721 }
19479
19480 233 void moneysign()
19481 {
19482 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19483 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19484 233 set_clip_state(pricesdisplaybuf, 0);
19485 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19486 233 }
19487
19488 3303 void putprices(bool sign)
19489 {
19490
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3271 times.
3303 if(fadeclk > 0) return;
19491
19492 3271 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19493 3271 int32_t step=32;
19494 3271 int32_t x=80;
19495
19496
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2990 times.
3271 if(prices[2]==0)
19497 {
19498 2990 step<<=1;
19499
19500
2/2
✓ Branch 0 taken 2958 times.
✓ Branch 1 taken 32 times.
2990 if(prices[1]==0)
19501 {
19502 2958 x=112;
19503 2958 }
19504 2990 }
19505
19506
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 9813 times.
13084 for(int32_t i=0; i<3; i++)
19507 {
19508 // Kind of stupid, but it works: 100000 is used to indicate that an item
19509 // has a price of zero rather than there being no item.
19510 // 100000 isn't a valid price, so this doesn't cause problems.
19511
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8774 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9813 if(prices[i]!=0 && prices[i]<100000)
19512 {
19513 char buf[8];
19514 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19515
19516 1039 int32_t l=(int32_t)strlen(buf);
19517 1039 set_clip_state(pricesdisplaybuf, 0);
19518
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19519 1039 }
19520
19521 9813 x+=step;
19522 9813 }
19523 3303 }
19524
19525 // Setting up special rooms
19526 // Also called when the Letter is used successfully.
19527 1210 void setupscreen()
19528 {
19529 1210 boughtsomething=false;
19530
19531 // Either the origin screen, or if in a 0x80 room the screen player came from.
19532
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19533 1210 mapscr* scr = origin_scr;
19534
19535 1210 word str=base_scr->str;
19536
19537 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19538
19539 // Prices are already set to 0 in dowarp()
19540
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19541 {
19542 case rSP_ITEM: // special item
19543 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19544 164 break;
19545
19546 case rINFO: // pay for info
19547 {
19548 28 int32_t count = 0;
19549 28 int32_t base = 88;
19550 28 int32_t step = 5;
19551
19552 28 moneysign();
19553
19554
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19555 {
19556
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19557 {
19558 84 ++count;
19559 84 }
19560 else
19561 break;
19562 84 }
19563
19564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19565 {
19566
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19567 {
19568 base = 88+32;
19569 }
19570
19571
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19572 {
19573 step = 6;
19574 }
19575
19576
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19577 {
19578 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19579 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19580 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19581
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19582 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19583 84 int32_t itemid = current_item_id(itype_wealthmedal);
19584
19585
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19586 {
19587 if(itemsbuf[itemid].flags & item_flag1)
19588 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19589 else
19590 prices[i]-=itemsbuf[itemid].misc1;
19591 prices[i]=vbound(prices[i], -99999, 0);
19592 if(prices[i]==0)
19593 prices[i]=100000;
19594 }
19595
19596
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19597 prices[i]=-1;
19598 84 }
19599 28 }
19600
19601 28 break;
19602 }
19603
19604 case rMONEY: // secret money
19605 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19606 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19607 44 break;
19608
19609 case rGAMBLE: // gambling
19610 11 prices[0]=prices[1]=prices[2]=-10;
19611 11 moneysign();
19612 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19613 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19614 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19615 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19616 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19617 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19618 11 break;
19619
19620 case rREPAIR: // door repair
19621
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19622 // }
19623 13 repaircharge=base_scr->catchall;
19624 13 break;
19625
19626 case rMUPGRADE: // upgrade magic
19627 2 adjustmagic=true;
19628 2 break;
19629
19630 case rLEARNSLASH: // learn slash attack
19631 2 learnslash=true;
19632 2 break;
19633
19634 case rRP_HC: // heart container or red potion
19635 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19636 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19637 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19638 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19639 17 break;
19640
19641 case rP_SHOP: // potion shop
19642
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19643 {
19644 12 str=0;
19645 12 break;
19646 }
19647
19648 [[fallthrough]];
19649 case rTAKEONE: // take one
19650 case rSHOP: // shop
19651 {
19652 194 int32_t count = 0;
19653 194 int32_t base = 88;
19654 194 int32_t step = 5;
19655
19656
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19657 193 moneysign();
19658
19659 //count and align the stuff
19660
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19661 {
19662
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19663 {
19664 523 ++count;
19665 523 }
19666 else
19667 {
19668 37 break;
19669 }
19670 523 }
19671
19672
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19673 {
19674 22 base = 88+32;
19675 22 }
19676
19677
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19678 {
19679 15 step = 6;
19680 15 }
19681
19682
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19683 {
19684 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19685 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19686
19687
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19688 {
19689 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19690
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19691 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19692 521 int32_t itemid = current_item_id(itype_wealthmedal);
19693
19694
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19695 {
19696
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19697 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19698 else
19699 prices[i]+=itemsbuf[itemid].misc1;
19700 9 prices[i]=vbound(prices[i], 0, 99999);
19701
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19702 prices[i]=100000;
19703 9 }
19704
19705
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19706 prices[i]=1;
19707 521 }
19708 523 }
19709
19710 194 break;
19711 }
19712 case rBOTTLESHOP: // bottle shop
19713 {
19714 1 int32_t count = 0;
19715 1 int32_t base = 88;
19716 1 int32_t step = 5;
19717
19718 1 moneysign();
19719 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19720 //count and align the stuff
19721
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19722 {
19723
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19724 {
19725 3 ++count;
19726 3 }
19727 else
19728 {
19729 break;
19730 }
19731 3 }
19732
19733
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19734 {
19735 base = 88+32;
19736 }
19737
19738
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19739 {
19740 step = 6;
19741 }
19742
19743
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19744 {
19745 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19746 //{ Setup dummy item
19747 3 item* curItem = ((item*)items.spr(items.Count()-1));
19748 3 curItem->PriceIndex = i;
19749 3 newcombo const& cmb = combobuf[bst.comb[i]];
19750
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19751 {
19752 curItem->yofs = -32768;
19753 }
19754 3 curItem->o_tile = cmb.o_tile;
19755 3 curItem->o_cset = bst.cset[i];
19756 3 curItem->cs = curItem->o_cset;
19757 3 curItem->tile = cmb.o_tile;
19758 3 curItem->o_speed = cmb.speed;
19759 3 curItem->o_delay = 0;
19760 3 curItem->frames = cmb.frames;
19761 3 curItem->flip = cmb.flip;
19762 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19763 3 curItem->pstring = 0;
19764 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19765 3 curItem->flash = false;
19766 3 curItem->twohand = false;
19767 3 curItem->anim = true;
19768 3 curItem->hit_width=1;
19769 3 curItem->hyofs=4;
19770 3 curItem->hit_height=12;
19771 3 curItem->script=0;
19772 3 curItem->txsz=1;
19773 3 curItem->tysz=1;
19774 //}
19775
19776 3 prices[i] = bst.price[i];
19777
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19778 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19779 3 int32_t itemid = current_item_id(itype_wealthmedal);
19780
19781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19782 {
19783 if(itemsbuf[itemid].flags & item_flag1)
19784 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19785 else
19786 prices[i]+=itemsbuf[itemid].misc1;
19787 prices[i]=vbound(prices[i], 0, 99999);
19788 if(prices[i]==0)
19789 prices[i]=100000;
19790 }
19791
19792
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19793 prices[i]=1;
19794 3 }
19795
19796 1 break;
19797 }
19798
19799 case rBOMBS: // more bombs
19800 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19801 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19802 19 prices[0]=-base_scr->catchall;
19803 19 break;
19804
19805 case rARROWS: // more arrows
19806 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19807 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19808 prices[0]=-base_scr->catchall;
19809 break;
19810
19811 case rSWINDLE: // leave heart container or money
19812 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19813 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19814 14 prices[0]=-1;
19815 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19816 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19817 14 prices[1]=-base_scr->catchall;
19818 14 break;
19819
19820 }
19821
19822
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19823 {
19824 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19825 19 int32_t itemid = current_item_id(itype_wealthmedal);
19826
19827
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19828 {
19829 if(itemsbuf[itemid].flags & item_flag1)
19830 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19831 else
19832 prices[i]+=itemsbuf[itemid].misc1;
19833 }
19834
19835
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19836 prices[i]=-1;
19837 19 }
19838
19839 1210 putprices(false);
19840
19841
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19842 {
19843 1151 donewmsg(base_scr, str);
19844 1151 }
19845 else
19846 {
19847 59 Hero.unfreeze();
19848 }
19849 1210 }
19850
19851 enum
19852 {
19853 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19854 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19855
19856 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19857
19858 MNU_DATA_MAX
19859 };
19860 struct menu_choice
19861 {
19862 int32_t x, y;
19863 int32_t pos;
19864 int32_t upos, dpos, lpos, rpos;
19865 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19866 18 {}
19867 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19868 int32_t dpos, int32_t lpos, int32_t rpos)
19869 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19870 18 {}
19871 };
19872 static int32_t msg_menu_data[MNU_DATA_MAX];
19873 static bool do_run_menu = false;
19874 bool do_end_str = false;
19875 static bool wait_advance = false;
19876 412 static std::map<int32_t, menu_choice> menu_options;
19877 43871 void clr_msg_data()
19878 {
19879 43871 do_end_str = false;
19880 43871 wait_advance = false;
19881 43871 do_run_menu = false;
19882 43871 menu_options.clear();
19883 43871 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19884 43871 }
19885
19886 static char namebuf[9] = {0};
19887 static char* nameptr = NULL;
19888 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19889 2036 bool runMenuCursor()
19890 {
19891 2036 clear_bitmap(msg_menu_bmp_buf);
19892
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19893 {
19894 msg_menu_data[MNU_CHOSEN] = 0;
19895 return true; //end menu
19896 }
19897 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19898 //If the cursor is at an invalid pos, find the first pos >= 0...
19899
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19900 {
19901 pos = 0;
19902 while(menu_options.find(pos) == menu_options.end())
19903 ++pos;
19904 }
19905 2036 menu_choice* ch = &menu_options[pos];
19906
19907 2036 bool pressed = true;
19908
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19909
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19910
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19911
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19912 2010 else pressed = false;
19913
19914
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19915 26 msg_menu_data[MNU_TIMER] = 1;
19916
19917 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19918 2036 bool held = false;
19919
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19920 {
19921 90 held = true;
19922
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19926 89 else held = false;
19927 90 }
19928 //If the cursor is at an invalid pos, find the first pos >= 0...
19929
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19930 {
19931 pos = 0;
19932 while(menu_options.find(pos) == menu_options.end())
19933 ++pos;
19934 }
19935
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19936 27 sfx(MsgStrings[msgstr].sfx);
19937
19938 2036 ch = &menu_options[pos];
19939 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19940 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19941 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19942 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19943
19944 2036 msg_menu_data[MNU_CHOSEN] = pos;
19945
19946
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19947 {
19948 603 rAbtn(); //Eat
19949
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19950 603 }
19951
19952
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19953 //Eat inputs
19954 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19955
19956
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19957 5 menu_options.clear();
19958
19959 2036 return ret;
19960 //false if pos changed this frame; no confirming while moving the cursor!
19961 2036 }
19962
19963 839994 bool bottom_margin_clip()
19964 {
19965 891831 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19966
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 51837 times.
839994 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19967 }
19968
19969 void update_msgstr();
19970
19971 3293 static bool parsemsgcode(const StringCommand& command)
19972 {
19973 3293 auto& args = command.args;
19974 3293 int last_arg = 0;
19975
19976
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19977 {
19978 case MSGC_NEWLINE:
19979 {
19980 1280 ssc_tile_hei = ssc_tile_hei_buf;
19981
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19982 1280 ssc_tile_hei_buf = -1;
19983 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19984 1280 cursor_x=msg_margins[left];
19985 1280 return true;
19986 }
19987
19988 case MSGC_COLOUR:
19989 {
19990 1644 int32_t cset = args[0];
19991 1644 msgcolour = CSET(cset)+(args[1]);
19992 1644 return true;
19993 }
19994
19995 case MSGC_SHDCOLOR:
19996 {
19997 int32_t cset = args[0];
19998 msg_shdcol = CSET(cset)+args[1];
19999 return true;
20000 }
20001 case MSGC_SHDTYPE:
20002 {
20003 msg_shdtype = args[0];
20004 return true;
20005 }
20006
20007 case MSGC_SPEED:
20008 {
20009 56 msgspeed=args[0];
20010 56 return true;
20011 }
20012
20013 case MSGC_CTRUP:
20014 {
20015 int32_t a1 = args[0];
20016 int32_t a2 = args[1];
20017 game->change_counter(a2, a1);
20018 return true;
20019 }
20020
20021 case MSGC_CTRDN:
20022 {
20023 5 int32_t a1 = args[0];
20024 5 int32_t a2 = args[1];
20025 5 game->change_counter(-a2, a1);
20026 5 return true;
20027 }
20028
20029 case MSGC_CTRSET:
20030 {
20031 7 int32_t a1 = args[0];
20032 7 int32_t a2 = args[1];
20033 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20034 7 return true;
20035 }
20036
20037 case MSGC_CTRUPPC:
20038 case MSGC_CTRDNPC:
20039 case MSGC_CTRSETPC:
20040 {
20041 2 int32_t counter = args[0];
20042 2 int32_t amount = args[1];
20043 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20044
20045
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20046 amount*=-1;
20047
20048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20049 game->set_counter(amount, counter);
20050 else
20051 2 game->change_counter(amount, counter);
20052
20053 2 return true;
20054 }
20055
20056 case MSGC_GIVEITEM:
20057 {
20058 70 int32_t itemID = args[0];
20059
20060 70 getitem(itemID, true);
20061
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20062 {
20063 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20064 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20065 70 }
20066 70 return true;
20067 }
20068
20069
20070 case MSGC_WARP:
20071 {
20072 int32_t dmap = args[0];
20073 int32_t scrn = args[1];
20074 int32_t dx = args[2];
20075 int32_t dy = args[3];
20076 int32_t wfx = args[4];
20077 int32_t sfx = args[5];
20078 if(dx >= MAX_SCC_ARG) dx = -1;
20079 if(dy >= MAX_SCC_ARG) dy = -1;
20080 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20081 do_end_str = true;
20082 return true;
20083 }
20084
20085 case MSGC_SETSCREEND:
20086 {
20087 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20088 int32_t screen = args[1];
20089 int32_t reg = args[2];
20090 int32_t val = args[3];
20091 FFCore.set_screen_d(screen + dmap, reg, val);
20092 return true;
20093 }
20094 case MSGC_TAKEITEM:
20095 {
20096 11 int32_t itemID = args[0];
20097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20098 {
20099 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20100 }
20101 11 takeitem(itemID);
20102
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20103 {
20104 game->forced_bwpn = -1;
20105 } //not else if! -Z
20106
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20107 {
20108 game->forced_awpn = -1;
20109 }
20110
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20111 {
20112 game->forced_xwpn = -1;
20113 } //not else if! -Z
20114
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20115 {
20116 game->forced_ywpn = -1;
20117 }
20118 11 verifyBothWeapons();
20119 11 return true;
20120 }
20121
20122 case MSGC_SFX:
20123 {
20124 22 sfx(args[0]);
20125 22 return true;
20126 }
20127
20128 case MSGC_MIDI:
20129 {
20130 7 int32_t music = args[0];
20131
20132
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20133 1 music_stop();
20134 else
20135 6 jukebox(music+(ZC_MIDI_COUNT-1));
20136
20137 7 return true;
20138 }
20139
20140 case MSGC_FONT:
20141 {
20142 int fontid = args[0];
20143 int oh = text_height(msgfont);
20144 msgfont = get_zc_font(fontid);
20145 int nh = text_height(msgfont);
20146 int mh = std::max(oh,nh);
20147 if(mh > ssc_tile_hei_buf)
20148 ssc_tile_hei_buf = mh;
20149 return true;
20150 }
20151 case MSGC_RUN_FRZ_GENSCR:
20152 {
20153 word scr_id = args[0];
20154 bool force_redraw = args[1]!=0;
20155 if(force_redraw)
20156 {
20157 update_msgstr();
20158 draw_screen();
20159 }
20160 FFCore.runGenericFrozenEngine(scr_id);
20161 return true;
20162 }
20163 case MSGC_DRAWTILE:
20164 {
20165 int32_t tl = args[0];
20166 int32_t cs = args[1];
20167 int32_t t_wid = args[2];
20168 int32_t t_hei = args[3];
20169 int32_t fl = args[4];
20170
20171 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20172 {
20173 ssc_tile_hei = ssc_tile_hei_buf;
20174 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20175 ssc_tile_hei_buf = -1;
20176 cursor_y += thei + MsgStrings[msgstr].vspace;
20177 if(bottom_margin_clip()) return true;
20178 cursor_x=msg_margins[left];
20179 }
20180
20181 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20182 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20183 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20184 return true;
20185 }
20186
20187 case MSGC_GOTOIFRAND:
20188 {
20189 1 int32_t odds = args[0];
20190
20191 1 last_arg = 1;
20192
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20193 1 goto switched;
20194
20195 return true;
20196 }
20197
20198 case MSGC_GOTOIFGLOBAL:
20199 {
20200 int32_t arg = args[0];
20201 int32_t d = zc_min(7,arg);
20202 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20203 arg = args[1];
20204
20205 if(game->screen_d[s][d] >= arg)
20206 {
20207 last_arg = 2;
20208 goto switched;
20209 }
20210
20211 return true;
20212 }
20213
20214 case MSGC_CHANGEPORTRAIT:
20215 {
20216 return true; //not implemented
20217 }
20218
20219 case MSGC_GOTOIFCREEND:
20220 {
20221 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20222 int32_t screen = args[1];
20223 int32_t reg = args[2];
20224 int32_t val = args[3];
20225 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20226 {
20227 last_arg = 4;
20228 goto switched;
20229 }
20230 return true;
20231 }
20232
20233 case MSGC_GOTOIF:
20234 {
20235 122 int32_t it = args[0];
20236
20237
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20238 {
20239 35 last_arg = 1;
20240 35 goto switched;
20241 }
20242
20243 87 return true;
20244 }
20245
20246 case MSGC_GOTOIFCTR:
20247 {
20248
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20249 {
20250 14 last_arg = 2;
20251 14 goto switched;
20252 }
20253
20254 14 return true;
20255 }
20256
20257 case MSGC_GOTOIFCTRPC:
20258 {
20259 int32_t counter = args[0];
20260 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20261
20262 if(game->get_counter(counter)>=amount)
20263 {
20264 last_arg = 2;
20265 goto switched;
20266 }
20267
20268 return true;
20269 }
20270
20271 case MSGC_GOTOIFTRICOUNT:
20272 {
20273 if(TriforceCount() >= args[0])
20274 {
20275 last_arg = 1;
20276 goto switched;
20277 }
20278
20279 return true;
20280 }
20281
20282 case MSGC_GOTOIFTRI:
20283 {
20284 int32_t lev = args[0];
20285
20286 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20287 {
20288 last_arg = 1;
20289 goto switched;
20290 }
20291
20292 return true;
20293 }
20294
20295 case MSGC_SETUPMENU:
20296 {
20297 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20298 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20299 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20300 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20301 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20302 5 return true;
20303 }
20304
20305 case MSGC_MENUCHOICE:
20306 {
20307 18 int32_t pos = args[0];
20308 18 int32_t upos = args[1];
20309 18 int32_t dpos = args[2];
20310 18 int32_t lpos = args[3];
20311 18 int32_t rpos = args[4];
20312
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20313 {
20314 2 ssc_tile_hei = ssc_tile_hei_buf;
20315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20316 2 ssc_tile_hei_buf = -1;
20317 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20319 2 cursor_x=msg_margins[left];
20320 2 }
20321
20322 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20323 18 upos, dpos, lpos, rpos);
20324
20325
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20326 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20327 18 return true;
20328 }
20329
20330 case MSGC_RUNMENU:
20331 {
20332 5 msg_menu_data[MNU_CHOSEN] = 0;
20333 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20335 return true;
20336 5 do_run_menu = true;
20337 5 return true;
20338 }
20339
20340 case MSGC_GOTOMENUCHOICE:
20341 {
20342 7 int32_t choice = args[0];
20343
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20344 {
20345 5 last_arg = 1;
20346 5 goto switched;
20347 }
20348
20349 2 return true;
20350 }
20351
20352 case MSGC_ENDSTRING:
20353 {
20354 3 do_end_str = true;
20355 3 return true;
20356 }
20357 case MSGC_WAIT_ADVANCE:
20358 {
20359 wait_advance = true;
20360 linkedmsgclk = 51;
20361 return true;
20362 }
20363 case MSGC_TRIGSECRETS:
20364 {
20365 bool perm = args[0];
20366 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20367 if(perm)
20368 setmapflag(msgscr, mSECRET);
20369 return true;
20370 }
20371 case MSGC_TRIG_CMB_COPYCAT:
20372 {
20373 int copy_id = args[0];
20374 if(copy_id == byte(copy_id))
20375 trig_copycat(copy_id);
20376 return true;
20377 }
20378 case MSGC_SETSCREENSTATE:
20379 {
20380 int32_t flag = args[0];
20381 if(unsigned(flag)>=mMAXIND)
20382 {
20383 Z_error("SCC 133: Flag %d is invalid\n", flag);
20384 return true;
20385 }
20386 bool state = args[1];
20387 if(state)
20388 setmapflag(msgscr, 1<<flag);
20389 else
20390 unsetmapflag(msgscr, 1<<flag, true);
20391 return true;
20392 }
20393 case MSGC_SETSCREENSTATER:
20394 {
20395 int32_t map = args[0];
20396 int32_t scrid = args[1];
20397 if(map < 1 || map > map_count)
20398 {
20399 Z_error("SCC 134: Map %d is invalid\n", map);
20400 return true;
20401 }
20402 if(unsigned(scrid)>=0x80)
20403 {
20404 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20405 return true;
20406 }
20407
20408 int32_t flag = args[2];
20409 if(unsigned(flag)>=mMAXIND)
20410 {
20411 Z_error("SCC 134: Flag %d is invalid\n", flag);
20412 return true;
20413 }
20414 bool state = args[3];
20415 if(state)
20416 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20417 else
20418 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20419 return true;
20420 }
20421 switched:
20422 55 int32_t lev = args[last_arg];
20423
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20424
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20425 {
20426 setmsg(lev);
20427 }
20428 else
20429 {
20430 55 donewmsg(msgscr, lev);
20431 55 ssc_tile_hei_buf = -1;
20432 }
20433 55 putprices(false);
20434 55 return true;
20435 }
20436
20437 return false;
20438 3293 }
20439
20440 3299 static std::string parsemsgcode2(const StringCommand& command)
20441 {
20442
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20443 {
20444
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20445 }
20446 else
20447 {
20448 3293 parsemsgcode(command);
20449 }
20450
20451
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20452 3299 }
20453
20454 252704 static bool putmsgchar(bool play_sfx)
20455 {
20456 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20457 DCHECK(!msg_it->character.empty());
20458
20459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252704 times.
252704 if (bottom_margin_clip())
20460 return false;
20461
20462 // If the current word would overflow the margins, increment cursor to the next line.
20463 252704 const char* rem_word = msg_it->remaining_word();
20464 252704 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20465
4/4
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 247033 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 5081 times.
258283 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20466
4/4
✓ Branch 0 taken 5579 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5671 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20467 {
20468 5579 ssc_tile_hei = ssc_tile_hei_buf;
20469
1/2
✓ Branch 0 taken 5579 times.
✗ Branch 1 not taken.
5579 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20470 5579 ssc_tile_hei_buf = -1;
20471 5579 cursor_y += thei + MsgStrings[msgstr].vspace;
20472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5579 times.
5579 if (bottom_margin_clip()) return false;
20473
20474 5579 cursor_x = msg_margins[left];
20475 5579 }
20476
20477
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217745 times.
252704 if (play_sfx)
20478 217745 sfx(MsgStrings[msgstr].sfx);
20479
20480 // Print the character (unless it's just a space).
20481
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20482 193700 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20483
20484 // Move the cursor.
20485 252704 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20486
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20487 193700 cursor_x += MsgStrings[msgstr].hspace;
20488
20489 252704 return true;
20490 252704 }
20491
20492 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20493
20494 static void msg_tick_end(bool disappear = false);
20495 241762 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20496 {
20497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241762 times.
241762 if (msg_it->done())
20498 return msg_tick_exit;
20499
20500
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239731 times.
241762 if (!do_run_menu)
20501 {
20502
4/4
✓ Branch 0 taken 239731 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 239731 times.
✓ Branch 3 taken 3299 times.
243030 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20503 {
20504 3299 bool one_frame_command_delay = !replay_version_check(41);
20505 3299 std::string text = parsemsgcode2(msg_it->command);
20506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
3299 if (wait_advance)
20507 break;
20508
20509
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20510 {
20511
2/4
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3293 times.
✗ Branch 3 not taken.
3293 msg_it->set_buffer("");
20512 // Advance the iterator to run many commands in one frame.
20513
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20514
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20515 3293 }
20516 else
20517 {
20518
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20519
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20521 6 msg_it->post_segment_delay = 1;
20522 }
20523
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3299 times.
3299 }
20524
20525
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236554 times.
239731 if (msg_it->state == MsgStr::iterator::CHARACTER)
20526 {
20527
1/2
✓ Branch 0 taken 236554 times.
✗ Branch 1 not taken.
236554 if (!putmsgchar(play_sfx)) return msg_tick_break;
20528 236554 }
20529 239731 }
20530
20531 241762 bool wait_advance_check_early = !burst_mode;
20532
20533
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163273 times.
241762 if (wait_advance_check_early)
20534 {
20535
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163272 times.
163273 if (do_end_str)
20536 {
20537 1 msg_tick_end();
20538 1 return msg_tick_exit;
20539 }
20540
20541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163272 times.
163272 if (wait_advance)
20542 {
20543 msg_it->next();
20544 return msg_tick_exit;
20545 }
20546 163272 }
20547
20548
2/2
✓ Branch 0 taken 239725 times.
✓ Branch 1 taken 2036 times.
241761 if (do_run_menu)
20549 {
20550
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20551 {
20552 5 do_run_menu = false;
20553
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20554 {
20555 2 msg_it->next();
20556 2 return msg_tick(play_sfx, burst_mode);
20557 }
20558 3 }
20559 2031 else return msg_tick_break;
20560 3 }
20561
20562 239728 msg_it->next();
20563
20564
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 77955 times.
239728 if (!wait_advance_check_early)
20565 {
20566
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20567 {
20568 2 msg_tick_end();
20569 2 return msg_tick_exit;
20570 }
20571
20572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20573 return msg_tick_exit;
20574 77953 }
20575
20576
4/4
✓ Branch 0 taken 4007 times.
✓ Branch 1 taken 235719 times.
✓ Branch 2 taken 2017 times.
✓ Branch 3 taken 1990 times.
239726 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20577 {
20578
1/2
✓ Branch 0 taken 2017 times.
✗ Branch 1 not taken.
2017 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20579 setmsg(MsgStrings[msgstr].nextstring);
20580 2017 }
20581
20582 239726 return msg_tick_continue;
20583 241762 }
20584
20585 165560 static void msg_tick_end(bool disappear)
20586 {
20587
2/2
✓ Branch 0 taken 164547 times.
✓ Branch 1 taken 1013 times.
165560 if (disappear)
20588 1013 goto disappear;
20589
20590 // Done printing the string
20591
8/8
✓ Branch 0 taken 164544 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163047 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 159021 times.
✓ Branch 5 taken 4026 times.
✓ Branch 6 taken 159021 times.
✓ Branch 7 taken 4026 times.
164547 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20592 {
20593
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4026 times.
4029 if(!do_end_str)
20594 {
20595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026 times.
4026 while (msg_it->state == MsgStr::iterator::COMMAND)
20596 {
20597 parsemsgcode2(msg_it->command);
20598 msg_it->next();
20599 }
20600 4026 }
20601
20602 // Go to next string, or make it disappear by going to string 0.
20603
5/6
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4029 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20604 {
20605 3033 linkedmsgclk=do_end_str?1:51;
20606 3033 }
20607
20608
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
4029 if(MsgStrings[msgstr].nextstring==0)
20609 {
20610
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 996 times.
2010 if(!get_qr(qr_MSGDISAPPEAR))
20611 996 {
20612 disappear:
20613 2009 msg_active = false;
20614 2009 Hero.finishedmsg();
20615 2009 }
20616
20617
2/2
✓ Branch 0 taken 3010 times.
✓ Branch 1 taken 13 times.
3023 if(repaircharge)
20618 {
20619
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20620 13 repaircharge = 0;
20621 13 }
20622
20623
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(adjustmagic)
20624 {
20625
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20626 {
20627
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20628 2 game->set_magicdrainrate(1);
20629 2 }
20630 else if(game->get_magicdrainrate() > 1)
20631 {
20632 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20633 }
20634 2 adjustmagic = false;
20635 2 sfx(WAV_SCALE);
20636
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20637 2 }
20638
20639
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(learnslash)
20640 {
20641 2 game->set_canslash(1);
20642 2 learnslash = false;
20643 2 sfx(WAV_SCALE);
20644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20645 2 }
20646 3023 }
20647 5042 }
20648 165560 }
20649
20650 6228 static void msg_consume_spaces()
20651 {
20652
2/2
✓ Branch 0 taken 6228 times.
✓ Branch 1 taken 16150 times.
22378 while (msg_it->character == " ")
20653 {
20654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20655
20656 // Advance the iterator.
20657 16150 msg_it->next();
20658
20659 // The "Continue From Previous" feature
20660
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20661 {
20662 if(MsgStrings[msgstr].nextstring)
20663 {
20664 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20665 {
20666 setmsg(MsgStrings[msgstr].nextstring);
20667 }
20668 }
20669 }
20670 }
20671 6228 }
20672
20673 14618334 void putmsg()
20674 {
20675
2/2
✓ Branch 0 taken 681711 times.
✓ Branch 1 taken 13936623 times.
14618334 if(!msgorig) msgorig=msgstr;
20676
20677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14618334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14618334 if(wait_advance && linkedmsgclk < 1)
20678 linkedmsgclk = 1;
20679
2/2
✓ Branch 0 taken 14340154 times.
✓ Branch 1 taken 278180 times.
14618334 if(linkedmsgclk>0)
20680 {
20681
2/2
✓ Branch 0 taken 126729 times.
✓ Branch 1 taken 151451 times.
278180 if(linkedmsgclk==1)
20682 {
20683
6/6
✓ Branch 0 taken 126726 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123816 times.
✓ Branch 3 taken 2910 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123698 times.
126729 if(do_end_str||cAbtn()||cBbtn())
20684 {
20685 3031 do_end_str = false;
20686 3031 linkedmsgclk = 0;
20687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if(wait_advance)
20688 {
20689 wait_advance = false;
20690 }
20691 else
20692 {
20693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if (!msgscr) msgscr = hero_scr;
20694 3031 msgstr=MsgStrings[msgstr].nextstring;
20695 3031 ssc_tile_hei_buf = -1;
20696
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3031 if(!msgstr && enqueued_str)
20697 {
20698 msgstr = enqueued_str;
20699 enqueued_str = 0;
20700 }
20701
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
3031 if(!msgstr)
20702 {
20703 1013 msgfont=get_zc_font(font_zfont);
20704
20705
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20706 1009 blockpath=false;
20707
20708 1013 dismissmsg();
20709 1013 msg_tick_end(true);
20710 1013 return;
20711 }
20712
20713 2018 donewmsg(msgscr, msgstr);
20714 2018 putprices(false);
20715 }
20716 2018 }
20717 125716 }
20718 else
20719 {
20720 151451 --linkedmsgclk;
20721 }
20722 277167 }
20723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14617321 times.
14617321 if(wait_advance) return; //Waiting for buttonpress
20724
20725
9/10
✓ Branch 0 taken 14615366 times.
✓ Branch 1 taken 1955 times.
✓ Branch 2 taken 676780 times.
✓ Branch 3 taken 13938586 times.
✓ Branch 4 taken 263442 times.
✓ Branch 5 taken 413338 times.
✓ Branch 6 taken 259417 times.
✓ Branch 7 taken 4025 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259417 times.
14617321 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20726 {
20727
2/2
✓ Branch 0 taken 13938586 times.
✓ Branch 1 taken 417363 times.
14355949 if(!msgstr)
20728 13938586 msgorig=0;
20729
20730 14355949 msg_active = false;
20731 14355949 msg_it.reset();
20732 14355949 return;
20733 }
20734
20735
1/2
✓ Branch 0 taken 261372 times.
✗ Branch 1 not taken.
261372 if (!msg_it)
20736 return;
20737
20738 261372 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20739
20740
2/2
✓ Branch 0 taken 257323 times.
✓ Branch 1 taken 4049 times.
261372 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20741 {
20742 4049 msg_it->next();
20743 4049 msg_consume_spaces();
20744 4049 }
20745
20746 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20747 // as possible. This skips the character-by-character animation that usually renders a string
20748 // slowly over many frames.
20749
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 259991 times.
✓ Branch 2 taken 897 times.
✓ Branch 3 taken 259094 times.
261372 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20750 {
20751
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80231 while (!msg_it->done())
20752 {
20753
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20754 10 goto breakout; // break out if message speed was changed to non-zero
20755
20756 78489 auto tick = msg_tick(msg_it->character != " ", true);
20757
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20758 534 break;
20759
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20760 2 return;
20761 }
20762
20763
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20764 {
20765 1274 msgclk = 72;
20766 1274 }
20767 1808 }
20768 else
20769 259094 {
20770 breakout:
20771 259104 word tempspeed = msgspeed;
20772
2/2
✓ Branch 0 taken 258141 times.
✓ Branch 1 taken 963 times.
259104 if (do_run_menu)
20773 963 tempspeed = 0;
20774
6/6
✓ Branch 0 taken 207843 times.
✓ Branch 1 taken 51261 times.
✓ Branch 2 taken 121553 times.
✓ Branch 3 taken 86290 times.
✓ Branch 4 taken 111476 times.
✓ Branch 5 taken 10077 times.
259104 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20775 96367 return;
20776 }
20777
20778 // Process the next msg tick.
20779 // This will either print a single character, or process a single string command (with one
20780 // exception).
20781
3/4
✓ Branch 0 taken 163271 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163271 times.
164545 if (!msg_it->done() && !bottom_margin_clip())
20782 {
20783 // This may run an additional tick in the case of a string menu finishing: the first
20784 // tick wraps up the menu, and then a second tick processes the next character or command.
20785 163271 auto tick = msg_tick(true, false);
20786
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161774 times.
163271 if (tick == msg_tick_break)
20787 {
20788 1497 msg_tick_end();
20789 1497 return;
20790 }
20791
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 1 times.
161774 if (tick == msg_tick_exit)
20792 1 return;
20793
20794 // If the next two characters are spaces, consume all upcoming spaces now.
20795
13/20
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 159021 times.
✓ Branch 2 taken 159021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26249 times.
✓ Branch 5 taken 132772 times.
✓ Branch 6 taken 26249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26249 times.
✓ Branch 10 taken 135524 times.
✓ Branch 11 taken 26249 times.
✓ Branch 12 taken 2752 times.
✓ Branch 13 taken 159021 times.
✓ Branch 14 taken 159594 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
188022 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20796 2179 msg_consume_spaces();
20797 161773 }
20798
20799 163047 msg_tick_end();
20800 14617876 }
20801
20802 124732 int32_t message_more_y()
20803 {
20804 //Is the flag ticked, do we really want a message more y larger than 160?
20805
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124704 times.
✓ Branch 2 taken 124732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124704 times.
✓ Branch 5 taken 28 times.
124732 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20806 124732 msgy+=playing_field_offset;
20807 124732 return msgy;
20808 }
20809
20810 /*** Collision detection & handling ***/
20811
20812 14306378 void clear_script_one_frame_conditions()
20813 {
20814
2/2
✓ Branch 0 taken 38991403 times.
✓ Branch 1 taken 14306378 times.
53297781 for(int32_t j=0; j<guys.Count(); j++)
20815 {
20816 38991403 enemy *e = (enemy*)guys.spr(j);
20817
2/2
✓ Branch 0 taken 662853851 times.
✓ Branch 1 taken 38991403 times.
701845254 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20818 38991403 }
20819 14306378 }
20820
20821 4883715 void check_enemy_lweapon_collision(weapon *w)
20822 {
20823
8/8
✓ Branch 0 taken 4267271 times.
✓ Branch 1 taken 616444 times.
✓ Branch 2 taken 3271483 times.
✓ Branch 3 taken 995788 times.
✓ Branch 4 taken 3209341 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3192603 times.
4883715 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20824 {
20825
2/2
✓ Branch 0 taken 3176788 times.
✓ Branch 1 taken 11214738 times.
14391526 for(int32_t j=0; j<guys.Count(); j++)
20826 {
20827 11214738 enemy *e = (enemy*)guys.spr(j);
20828
20829 11214738 bool didhit = e->hit(w);
20830 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20831 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20832
2/2
✓ Branch 0 taken 10993873 times.
✓ Branch 1 taken 220865 times.
11214738 if(didhit)
20833 {
20834 // !(e->stunclk)
20835 220865 int32_t h = e->takehit(w);
20836
2/2
✓ Branch 0 taken 186989 times.
✓ Branch 1 taken 33876 times.
220865 if (h < 0) // hitby code
20837 {
20838 33876 int indx = Lwpns.find(w);
20839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33876 times.
33876 if(indx > -1)
20840 33876 e->hitby[HIT_BY_LWEAPON] = indx+1;
20841 33876 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20842 33876 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20843
2/2
✓ Branch 0 taken 31471 times.
✓ Branch 1 taken 2405 times.
33876 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
20844 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20845 33876 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20846 33876 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20847 //we may need to handle this in special cases. -Z
20848 // arrow item pierce flag, for example -Em
20849 33876 }
20850
20851
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 186989 times.
220865 if(h < 0) // hit, check if weapon is "out of pierces"
20852 33876 w->hit_pierce(e, h);
20853
2/2
✓ Branch 0 taken 176579 times.
✓ Branch 1 taken 10410 times.
186989 else if(h > 0) // blocked
20854 10410 w->onhit(false, e, h);
20855
2/2
✓ Branch 0 taken 218191 times.
✓ Branch 1 taken 2674 times.
220865 if(abs(h) == 2)
20856 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20857 218191 }
20858
20859
2/2
✓ Branch 0 taken 11198923 times.
✓ Branch 1 taken 13141 times.
11212064 if(w->Dead())
20860 {
20861 13141 break;
20862 }
20863 11198923 }
20864
20865 // Item flags added in 2.55:
20866 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20867 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20868 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20869 // -Em
20870
6/6
✓ Branch 0 taken 2738060 times.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 2693374 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44765 times.
✓ Branch 5 taken 2648609 times.
3192603 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20871 {
20872 543994 int32_t itype, pitem = w->parentitem;
20873
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 44765 times.
✓ Branch 3 taken 44686 times.
543994 switch(w->id)
20874 {
20875 454543 case wBrang: itype = itype_brang; break;
20876 44765 case wArrow: itype = itype_arrow; break;
20877 case wHookshot:
20878 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20879 44686 break;
20880 }
20881
2/2
✓ Branch 0 taken 538953 times.
✓ Branch 1 taken 5041 times.
543994 if(pitem < 0) pitem = current_item_id(itype);
20882
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 499308 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543994 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20883 { //Swap with item
20884 for(int32_t j=0; j<items.Count(); j++)
20885 {
20886 if(items.spr(j)->hit(w))
20887 {
20888 item *theItem = ((item*)items.spr(j));
20889 bool priced = theItem->PriceIndex >-1;
20890 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20891 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20892 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20893 {
20894 if(!Hero.switchhookclk)
20895 {
20896 hooked_comborpos = rpos_t::None;
20897 hooked_layerbits = 0;
20898 switching_object = theItem;
20899 theItem->switch_hooked = true;
20900 w->misc = 2;
20901 w->step = 0;
20902 theItem->clk2=256;
20903 Hero.doSwitchHook(game->get_switchhookstyle());
20904 if(QMisc.miscsfx[sfxSWITCHED])
20905 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
20906 }
20907 }
20908 }
20909 }
20910 }
20911
6/6
✓ Branch 0 taken 44765 times.
✓ Branch 1 taken 499229 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330174 times.
✓ Branch 4 taken 499229 times.
✓ Branch 5 taken 330174 times.
543994 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20912 {
20913
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20914 {
20915
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20916 {
20917 4898 item *theItem = ((item*)items.spr(j));
20918 4898 bool priced = theItem->PriceIndex >-1;
20919
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20920
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20921
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20922 {
20923
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20924 {
20925 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20926 }
20927
20928 1724 Hero.checkitems(j);
20929 1724 }
20930 4898 }
20931 88886 }
20932 374939 }
20933
2/2
✓ Branch 0 taken 15674 times.
✓ Branch 1 taken 153381 times.
829403 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20934 {
20935
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153381 times.
190281 for(int32_t j=0; j<items.Count(); j++)
20936 {
20937
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
20938 {
20939 8688 item *theItem = ((item*)items.spr(j));
20940 8688 bool priced = theItem->PriceIndex >-1;
20941
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20942
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20943
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20944 {
20945 7273 int32_t pickup = theItem->pickup;
20946 7273 int32_t id2 = theItem->id;
20947 7273 int32_t pstr = theItem->pstring;
20948 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20949
20950 7273 std::vector<int32_t> &ev = FFCore.eventData;
20951 7273 ev.clear();
20952 7273 ev.push_back(id2*10000);
20953 7273 ev.push_back(pickup*10000);
20954 7273 ev.push_back(pstr*10000);
20955 7273 ev.push_back(pstr_flags*10000);
20956 7273 ev.push_back(0);
20957 7273 ev.push_back(theItem->getUID());
20958 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20959 7273 ev.push_back(w->getUID());
20960
20961 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20962 7273 bool nullify = ev[4] != 0;
20963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20964
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20965 {
20966 6197 w->onhit(false);
20967 6197 }
20968
20969
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20970 {
20971 498 w->dead=1;
20972 498 theItem->clk2=256;
20973 498 w->dragging=j;
20974 498 theItem->is_dragged = true;
20975 498 }
20976 7273 }
20977 8688 }
20978 36900 }
20979 153381 }
20980 543994 }
20981 3192603 }
20982 4883715 }
20983 14304194 void check_collisions()
20984 {
20985
2/2
✓ Branch 0 taken 4883680 times.
✓ Branch 1 taken 14304194 times.
19187874 for(uint q = 0; q < Lwpns.Count(); ++q)
20986 4883680 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20987 14304194 }
20988
20989 14306378 void dragging_item()
20990 {
20991
2/2
✓ Branch 0 taken 5000289 times.
✓ Branch 1 taken 14306378 times.
19306667 for(int32_t i=0; i<Lwpns.Count(); i++)
20992 {
20993 5000289 weapon *w = (weapon*)Lwpns.spr(i);
20994
20995
4/4
✓ Branch 0 taken 4537151 times.
✓ Branch 1 taken 463138 times.
✓ Branch 2 taken 4844927 times.
✓ Branch 3 taken 155362 times.
5000289 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20996 {
20997
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155362 if(w->dragging>=0 && w->dragging<items.Count())
20998 {
20999 7247 item* dragItem = (item*)items.spr(w->dragging);
21000 7247 dragItem->x=w->x;
21001 7247 dragItem->y=w->y;
21002
21003 // Drag the Fairy enemy as well as the Fairy item
21004 7247 int32_t id = dragItem->id;
21005
21006
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21007 {
21008 404 movefairynew2(w->x,w->y,*dragItem);
21009 404 }
21010 7247 }
21011 155362 }
21012 5000289 }
21013 14306378 }
21014
21015 57 int32_t more_carried_items(int screen)
21016 {
21017 57 int32_t hasmorecarries = 0;
21018
21019
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21020 {
21021 64 auto spr = (item*)items.spr(i);
21022
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21023 {
21024 57 hasmorecarries++;
21025 57 }
21026 64 }
21027
21028 57 return hasmorecarries;
21029 }
21030
21031 36535 static int count_guys_from_screen(int screen)
21032 {
21033 36535 int count = 0;
21034
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21035 {
21036
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21037 201333 count += 1;
21038 237871 }
21039 36535 return count;
21040 }
21041
21042 // messy code to do the enemy-carrying-the-item thing
21043 14694306 static void roaming_item(mapscr* scr)
21044 {
21045 14694306 int screen = scr->screen;
21046 14694306 auto& state = get_screen_state(screen);
21047
4/4
✓ Branch 0 taken 14657833 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14657771 times.
✓ Branch 3 taken 36535 times.
14694306 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21048 14657771 return;
21049
21050 // All enemies already dead upon entering a room?
21051
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21052 {
21053 return;
21054 }
21055
21056 36535 int guycarryingitem = -1;
21057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21058 {
21059 84544 enemy* e = (enemy*)guys.spr(j);
21060
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21061 {
21062 36535 guycarryingitem=j;
21063 36535 break;
21064 }
21065 48009 }
21066
21067
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21068 {
21069
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21070 {
21071 return; //eSHOOTFBALL are alive but enemies from the list
21072 } //are not. Defer to HeroClass::checkspecial().
21073
21074 77 int32_t Item=scr->item;
21075
21076 77 state.item_state = ScreenItemState::None;
21077
21078
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21079 {
21080 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21081 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21082
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21083 );
21084 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21085 77 state.item_state = ScreenItemState::CarriedByEnemy;
21086 77 }
21087 else
21088 {
21089 return;
21090 }
21091 77 }
21092
21093
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21094 {
21095
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21096 {
21097
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21098 {
21099 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21100 22240 items.spr(i)->y = -128;
21101 22240 }
21102
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21103 {
21104
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21105 {
21106 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21107 {
21108 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21109 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21110 }
21111 else
21112 {
21113 if(guys.spr(guycarryingitem)->extend >= 3)
21114 {
21115 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21116 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21117 }
21118 else
21119 {
21120 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21121 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21122 }
21123 }
21124 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21125 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21126 }
21127 else
21128 {
21129 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21130 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21131 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21132 }
21133 14295 }
21134 36535 }
21135 46044 }
21136 14694306 }
21137
21138 14306378 void roaming_item()
21139 {
21140 29000684 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21141 14694306 roaming_item(scr);
21142 14694306 });
21143 14306378 }
21144
21145 bool enemy::IsBigAnim()
21146 {
21147 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21148 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21149 || anim == a4FRM8DIRB);
21150 }
21151 2418852 int32_t enemy::getFlashingCSet()
21152 {
21153 //Special cset for the dying sprite
21154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if(dying)
21155 {
21156 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21157 return wpnsbuf[spr_death].csets & 15;
21158 else
21159 return (((clk2 + 5) >> 1) & 3) + 6;
21160 }
21161
21162 //Normal cset
21163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if (hclk <= 0)
21164 {
21165 //Special cset for the flashing animation
21166 if (flags & guy_flashing)
21167 return (frame & 3) + 6;
21168 return cs;
21169 }
21170
21171 //Hurt animations
21172
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2414964 times.
2418852 if(type==eeGANON)
21173 3888 return (((hclk-1)>>1)&3)+6;
21174
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169944 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414964 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21175 1757882 return (((hclk-1)>>1)&3)+6;
21176
21177 657082 return cs;
21178 2418852 }
21179
21180 81975581 bool enemy::is_hitflickerframe(bool olddrawing)
21181 {
21182
6/6
✓ Branch 0 taken 81947077 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3972522 times.
✓ Branch 3 taken 77974555 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 772691 times.
81975581 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21183 81202890 return false;
21184
21185
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21186 return false;
21187
21188 772691 int32_t fr = game->get_spriteflickerspeed();
21189
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21190 return true;
21191 772691 return frame % (fr * 2) < fr;
21192 81975581 }
21193
21194 const char *old_guy_string[OLDMAXGUYS] =
21195 {
21196 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21197 // 020
21198 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21199 // 025
21200 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21201 // 030
21202 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21203 // 035
21204 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21205 // 040
21206 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21207 // 045
21208 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21209 // 050
21210 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21211 // 055
21212 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21213 // 060
21214 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21215 // 065
21216 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21217 // 070
21218 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21219 // 075
21220 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21221 // 080
21222 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21223 // 085
21224 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21225 // 090
21226 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21227 // 095
21228 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21229 // 100
21230 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21231 // 105
21232 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21233 // 110
21234 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21235 // 115
21236 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21237 // 120
21238 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21239 // 125
21240 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21241 // 130
21242 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21243 // 135
21244 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21245 // 140
21246 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21247 // 145
21248 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21249 // 150
21250 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21251 // 155
21252 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21253 // 160
21254 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21255 // 165
21256 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21257 // 170
21258 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21259 // 175
21260 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21261 };
21262
21263 15687886 int32_t enemy::get_dmisc(byte index)
21264 {
21265
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21266 {
21267 14611 case 0: return dmisc1;
21268 15885 case 1: return dmisc2;
21269 3236 case 2: return dmisc3;
21270 7390 case 3: return dmisc4;
21271 2144 case 4: return dmisc5;
21272 1794 case 5: return dmisc6;
21273 1051 case 6: return dmisc7;
21274 250 case 7: return dmisc8;
21275 1852 case 8: return dmisc9;
21276 1822 case 9: return dmisc10;
21277 7793452 case 10: return dmisc11;
21278 7597384 case 11: return dmisc12;
21279 case 12: return dmisc13;
21280 308 case 13: return dmisc14;
21281 case 14: return dmisc15;
21282 40 case 15: return dmisc16;
21283 case 16: return dmisc17;
21284 216 case 17: return dmisc18;
21285 case 18: return dmisc19;
21286 case 19: return dmisc20;
21287 case 20: return dmisc21;
21288 case 21: return dmisc22;
21289 case 22: return dmisc23;
21290 case 23: return dmisc24;
21291 884 case 24: return dmisc25;
21292 1120 case 25: return dmisc26;
21293 331 case 26: return dmisc27;
21294 238061 case 27: return dmisc28;
21295 case 28: return dmisc29;
21296 case 29: return dmisc30;
21297 case 30: return dmisc31;
21298 6055 case 31: return dmisc32;
21299 }
21300
21301 return 0;
21302 15687886 }
21303
21304 312 void enemy::set_dmisc(byte index, int32_t value)
21305 {
21306
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21307 {
21308 case 0: dmisc1 = value; break;
21309 case 1: dmisc2 = value; break;
21310 case 2: dmisc3 = value; break;
21311 case 3: dmisc4 = value; break;
21312 case 4: dmisc5 = value; break;
21313 case 5: dmisc6 = value; break;
21314 case 6: dmisc7 = value; break;
21315 case 7: dmisc8 = value; break;
21316 case 8: dmisc9 = value; break;
21317 case 9: dmisc10 = value; break;
21318 case 10: dmisc11 = value; break;
21319 case 11: dmisc12 = value; break;
21320 case 12: dmisc13 = value; break;
21321 case 13: dmisc14 = value; break;
21322 case 14: dmisc15 = value; break;
21323 case 15: dmisc16 = value; break;
21324 case 16: dmisc17 = value; break;
21325 case 17: dmisc18 = value; break;
21326 case 18: dmisc19 = value; break;
21327 case 19: dmisc20 = value; break;
21328 case 20: dmisc21 = value; break;
21329 case 21: dmisc22 = value; break;
21330 case 22: dmisc23 = value; break;
21331 case 23: dmisc24 = value; break;
21332 case 24: dmisc25 = value; break;
21333 case 25: dmisc26 = value; break;
21334 4 case 26: dmisc27 = value; break;
21335 24 case 27: dmisc28 = value; break;
21336 case 28: dmisc28 = value; break;
21337 case 29: dmisc30 = value; break;
21338 case 30: dmisc31 = value; break;
21339 284 case 31: dmisc32 = value; break;
21340 }
21341 312 }
21342